Post by Trad on Jun 14, 2003 16:40:30 GMT -5
Ok this is here for people to learn from, you will have to paste this link into your browser to download the program
(if you click it, you will probably get redirected by brinkster, so copy and paste it)
"http://www23.brinkster.com/tradsworld/html.zip"
here is the source
Any questions... ask here.
(if you click it, you will probably get redirected by brinkster, so copy and paste it)
"http://www23.brinkster.com/tradsworld/html.zip"
here is the source
#include <windows.h>
#include <urlmon.h>
#include <fstream.h>
#pragma comment(lib, "urlmon.lib")
#define IDC_MAINEDIT 100
#define IDC_MAINBUTTON 101
#define IDC_MAINEDITLINK 102
#define IDC_COPY 103
HFONT hFontComicSans = CreateFont(15,0,0,0,400,0,0,0,DEFAULT_CHARSET,OUT_CHARACTER_PRECIS,CLIP_DEFAULT_PRECIS,ANTIALIASED_QUALITY,FF_DONTCARE,"Comic Sans MS");
HFONT hFontArial = CreateFont(15,0,0,0,400,0,0,0,DEFAULT_CHARSET,OUT_CHARACTER_PRECIS,CLIP_DEFAULT_PRECIS,ANTIALIASED_QUALITY,FF_DONTCARE,"Arial");
HWND hWndEditLink;
HWND hWndEdit;
HWND hWndCopyButton;
ifstream tempdownloadfile;
char szURL[900];
char szFile[MAX_PATH];
char buffer[1000];
void AppendToEditBox(HWND hWndEdit, char *szText)
{
int nTextLength = (int)SendMessage(hWndEdit, WM_GETTEXTLENGTH, 0, 0);
SendMessage(hWndEdit, EM_SETSEL, nTextLength, nTextLength);
SendMessage(hWndEdit, EM_REPLACESEL, false, (LPARAM)szText);
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
switch (Msg)
{
case WM_CREATE[img]http://proboards8.com/boardimages/sad.gif[/img]br] {.
HINSTANCE hInstance = GetModuleHandle(NULL);
hWndEdit = CreateWindowEx(0,"Edit","",WS_CHILD | WS_VISIBLE | ES_MULTILINE | WS_VSCROLL | WS_HSCROLL,10,50,470,260,hWnd,(HMENU)IDC_MAINEDIT,hInstance,NULL);
hWndEditLink = CreateWindowEx(0,"EDIT","Enter Link And Press 'Get HTML'",WS_CHILD | WS_VISIBLE,20,15,370,20,hWnd,(HMENU)IDC_MAINEDITLINK,hInstance,NULL);
HWND hWndButton = CreateWindowEx(0,"BUTTON","Get HTML",WS_CHILD | WS_VISIBLE,400,10,75,30,hWnd,(HMENU)IDC_MAINBUTTON,hInstance,NULL);
hWndCopyButton = CreateWindowEx(0,"BUTTON","Copy",WS_CHILD | WS_VISIBLE,200,315,50,25,hWnd,(HMENU)IDC_COPY,hInstance,NULL);
SendMessage(hWndButton,WM_SETFONT,(WPARAM)hFontComicSans,(LPARAM)true);
SendMessage(hWndEditLink,WM_SETFONT,(WPARAM)hFontComicSans,(LPARAM)true);
SendMessage(hWndCopyButton,WM_SETFONT,(WPARAM)hFontComicSans,(LPARAM)true);
EnableWindow(GetDlgItem(hWnd, IDC_COPY), FALSE);
SendMessage(hWndEdit,WM_SETFONT,(WPARAM)hFontArial,(LPARAM)true);
SendMessage(hWndEditLink,EM_SETSEL,0,-1);
SetFocus(hWndEditLink);
return 0;
}
case WM_COMMAND[img]http://proboards8.com/boardimages/sad.gif[/img]br] {
switch (LOWORD(wParam)) {
case IDC_MAINBUTTON[img]http://proboards8.com/boardimages/sad.gif[/img]br] SetWindowText(hWndEdit,"");
EnableWindow(GetDlgItem(hWnd, IDC_COPY), FALSE);
lstrcpy(szFile,"tempurldownload.txt");
SendMessage(hWndEditLink,WM_GETTEXT,(WPARAM)100,(LPARAM)szURL);
if (URLDownloadToFile(0,szURL,szFile,0,NULL) == S_OK) {
tempdownloadfile.open("tempurldownload.txt");
if (tempdownloadfile.is_open()) {
while (!tempdownloadfile.eof()) {
tempdownloadfile >> buffer;
AppendToEditBox(hWndEdit,buffer);
}
}
}
tempdownloadfile.close();
EnableWindow(GetDlgItem(hWnd, IDC_COPY), TRUE);
break;
case IDC_COPY[img]http://proboards8.com/boardimages/sad.gif[/img]br] int length = SendMessage(hWndEdit,WM_GETTEXTLENGTH,0,0);
SendMessage(hWndEdit,EM_SETSEL,0,length);
SendMessage(hWndEdit,WM_COPY,0,0);
}
return 0;
}
case WM_CLOSE[img]http://proboards8.com/boardimages/sad.gif[/img]br] {
DestroyWindow(hWnd);
return 0;
}
case WM_DESTROY[img]http://proboards8.com/boardimages/sad.gif[/img]br] {
PostQuitMessage(0);
return 0;
}
default[img]http://proboards8.com/boardimages/sad.gif[/img]br] return DefWindowProc(hWnd, Msg, wParam, lParam); // Use the default message handler
}
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
WNDCLASs** WndClass**;
WndClass**.cbSize = sizeof(WndClass**);
WndClass**.cbCls**tra = 0; // No extra storage
WndClass**.cbWndExtra = 0; // No extra storage
WndClass**.hbrBackground = (HBRUSH)COLOR_BTNSHADOW; // Background
WndClass**.hCursor = LoadCursor(NULL, IDC_CROSS); // Default arrow cursor
WndClass**.hIcon = LoadIcon(NULL, IDI_APPLICATION); // Default app icon
WndClass**.hIconSm = LoadIcon(NULL, IDI_APPLICATION); // Default app icon
WndClass**.hInstance = hInstance; // Application instance
WndClass**.lpfnWndProc = WndProc; // Message Procedure
WndClass**.lpszClassName = "Window Class"; // Class name
WndClass**.lpszMenuName = NULL; // No menu
WndClass**.style = CS_VREDRAW | CS_HREDRAW | CS_OWNDC; // Class styles
if (!RegisterClass**(&WndClass**))
{
MessageBox(NULL, "Unable to register window class.", "Error", MB_ICONERROR);
return 0;
}
HWND hWnd = CreateWindowEx(NULL, "Window Class", "Get HTML", WS_VISIBLE | WS_OVERLAPPEDWINDOW, 200, 200, 500, 380, NULL, NULL, hInstance, NULL);
if (hWnd == NULL)
{
MessageBox(NULL, "Unable to create window.", "Error", MB_ICONERROR);
return 0;
}
MSG Msg;
while (GetMessage(&Msg, NULL, 0, 0) > 0)
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return 0;
}
Any questions... ask here.