   Obscure
  Hi! I can't seem to find what's wrong with this code. IError always reports error code 0: 'The operation completed successfully.' ... I mean WTF??? Taking away the Error Handling doesn't work either, the window just doesn't show.wc.cbClsExtra = 0;wc.cbWndExtra = 0;wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;wc.hbrBackground = GetSysColorBrush(COLOR_BTNFACE);wc.hCursor = LoadCursor(NULL, IDC_ARROW);wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));wc.hInstance = hInstance;wc.lpfnWndProc = WndProc;wc.lpszClassName = "TextAnalyzer123143";wc.lpszMenuName = NULL;if(!RegisterClass(&wc)){IError::ThrowWin32("RegisterClass");return 0;}hWnd = CreateWindow("TextAnalyzer123143", "Text Analyzer", WS_OVERLAPPEDWINDOW,0, 0, 640, 480, NULL, NULL,hInstance, NULL);if(!hWnd){IError::ThrowWin32("CreateWindow");return 0;}Any help would be appreciated!   
  ... WS_OPERLAPPEDWINDOW | WS_VISIBLE ... :)   ;  You should set the cbSize member of the wc struct:wc.cbSize   = sizeof(WNDCLASSEX);Also call these after CreateWindowShowWindow(hWnd, nCmdShow);UpdateWindow(hWnd);edit:WS_VISIBLE should do the same trick as ShowWindow   ;Quote:Original post by pulpfistYou should set the cbSize member of the wc struct:wc.cbSize   = sizeof(WNDCLASSEX);Also call these after CreateWindowShowWindow(hWnd, nCmdShow);UpdateWindow(hWnd);edit:WS_VISIBLE should do the same trick as ShowWindowHe's calling RegisterClass, so he must be using WNDCLASS. This structure has no such member. :)   ;  ShowWindow and UpdateWindow are never reached, and hWnd is NULL even after CreateWindow.[comment]Wow. Don't you guys hate it when this kind of thing happens to you? This is by far my first Win32 project (which was 3 years ago), and I can't seem to spot a difference between my previous projects and this one.Oh well...[/comment]   ;Quote:Original post by geekalertShowWindow and UpdateWindow are never reached, and hWnd is NULL even after CreateWindow.I just tried your code, it works fine...In your original post I see that you said RegisterClass/CreateWindow are never thrown, what changed?   ;  how about this:wc.hIcon  = LoadIcon(NULL, IDI_APPLICATION);wc.hIconSm  = LoadIcon(NULL, IDI_APPLICATION);I dont know if you need to set the hIconSm member, just an idea...   ;Quote:Original post by raz0rI just tried your code, it works fine...Uh oh. Brings bad memories for me... (hint: spyware/adware/malware with their goddamn DLL's that screw up my executables). I had to give up Windows programming until I reinstalled the OS 2 1/2 years ago.   ;  Update:#include "Main.h"int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrev, LPSTR lpCmdLine, int nCmdShow){WNDCLASSEX wc = {0};HWND hWnd;MSG msg;RECT rcDesired = {0, 0, 480, 640};wc.cbSize = sizeof(WNDCLASSEX);wc.cbClsExtra = 0;wc.cbWndExtra = 0;wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;wc.hbrBackground = GetSysColorBrush(COLOR_BTNFACE);wc.hCursor = LoadCursor(NULL, IDC_ARROW);wc.hIcon = (HICON) LoadImage(hInstance, MAKEINTRESOURCE(IDI_ICON1), IMAGE_ICON, 32, 32, LR_CREATEDIBSECTION);wc.hIconSm = (HICON) LoadImage(hInstance, MAKEINTRESOURCE(IDI_ICON1), IMAGE_ICON, 16, 16, LR_CREATEDIBSECTION);wc.hInstance = hInstance;wc.lpfnWndProc = WndProc;wc.lpszClassName = "TextAnalyzer123143";wc.lpszMenuName = NULL;if(!RegisterClassEx(&wc)){IError::ThrowWin32("RegisterClassEx");return 0;}AdjustWindowRect(&rcDesired, WS_OVERLAPPEDWINDOW, FALSE);rcDesired.right -= rcDesired.left;rcDesired.bottom -= rcDesired.top;hWnd = CreateWindow("TextAnalyzer123143", "Text Analyzer", WS_OVERLAPPEDWINDOW, (GetSystemMetrics(SM_CXSCREEN) - rcDesired.right) / 2, (GetSystemMetrics(SM_CYSCREEN) - rcDesired.bottom) / 2,rcDesired.right, rcDesired.bottom, GetDesktopWindow(), (HMENU) NULL, hInstance,NULL);if(!hWnd){IError::ThrowWin32("CreateWindowEx");return 0;}ShowWindow(hWnd, nCmdShow);UpdateWindow(hWnd);while(GetMessage(&msg, NULL, 0, 0) > 0){TranslateMessage(&msg);DispatchMessage(&msg);}return (int) msg.wParam;}You can safely assume that Main.h contains necessary functions/linkage.On my laptop: Error 6: Invalid handle.On my comp: Error 0: Operation completed successfuly.On my server: Error 2: System could not find the file specified.   