

While (GetMessage(&xMsg, NULL, 0, 0) > 0) MessageBoxA(NULL, "Window Creation Has Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK) If window creation fails, gib a messagebox which informs about that :+)
#SIMPLEFILE DOWNLOADER REGISTRATION#
MessageBoxA(NULL, "Window Registration Has Failed!", "Error", MB_ICONEXCLAMATION | MB_OK)

If the window registration fails gib me a messagebox which informs me about that :+) XWind.hIconSm = LoadIcon(NULL, IDI_APPLICATION) XWind.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1) XWind.hCursor = LoadCursor(NULL, IDC_ARROW) XWind.hIcon = LoadIcon(NULL, IDI_APPLICATION) Int xWindow(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) Return DefWindowProc(hwnd, msg, wParam, lParam) XProgressBar = CreateWindowEx(0, PROGRESS_CLASS, (LPTSTR)NULL, WS_CHILD | WS_VISIBLE, 43, 55, 700, 20, hwnd, (HMENU)X_PROG_BAR, xProgBar, NULL) XButton = CreateWindowEx(NULL, xButtonClick, xDownloadFile, WS_TABSTOP | WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON, 243, 100, 300, 20, hwnd, (HMENU)X_MAIN_BUTTON, xButtonShit, NULL) HTextBox = CreateWindowEx(NULL, 圎ditBtn, xUrlLink, WS_VISIBLE | WS_CHILD | WS_BORDER, 43, 10, 700, 20, hwnd, (HMENU)X_TEXT_BOX, hTextField, NULL) LRESULT CALLBACK xWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) WIN32 Window creation crap, creates a text box, button and progress bar, blahblahblah GetWindowText(GetDlgItem(hwnd, 1000), input, 100) IBindStatusCallback* callback = (IBindStatusCallback*)&progress ĭlFile = URLDownloadToFile(NULL, input, pathName, NULL, &progress) īOOL xDlFile(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
#SIMPLEFILE DOWNLOADER DOWNLOAD#
Get file path name with save as window, call IBindStatusCallback and download the file from urlĬString pathName = fileDlg.GetPathName() Separate Thread so the application doesnt freeze while downloading STDMETHOD(QueryInterface)(REFIID riid, void _RPC_FAR *_RPC_FAR *ppvObject) STDMETHOD(OnObjectAvailable)(REFIID riid, IUnknown _RPC_FAR *punk) STDMETHOD(OnDataAvailable)(DWORD grfBSCF, DWORD dwSize, FORMATETC _RPC_FAR *pformatetc, STGMEDIUM _RPC_FAR *pstgmed)

STDMETHOD(GetBindInfo)(DWORD _RPC_FAR *grfBINDF, BINDINFO _RPC_FAR *pbindinfo) STDMETHOD(OnStopBinding)(HRESULT hresult, LPCWSTR szError) Divides ulProgress by ulProgressMax and multiplies it with 100 to get %i out of 100% SendMessageA(xProgressBar, PBM_SETPOS, ((float)ulProgress / ((float)ulProgressMax > 0 ? (float)ulProgressMax : 100)) * 100, 0) Sends a message to the progress bar when urldownloadtofile is called STDMETHOD(OnProgress)(ULONG ulProgress, ULONG ulProgressMax, ULONG ulStatusCode, LPCWSTR wszStatusText) STDMETHOD(GetPriority)(LONG _RPC_FAR *pnPriority) STDMETHOD(OnStartBinding)(DWORD dwReserved, IBinding _RPC_FAR *pib) IBindStatusCallback - Used for the progress bar of the application with UrlDownloadToFileĬlass xDLStatus : public IBindStatusCallback
