Results 1 to 8 of 8

Thread: Win32

  1. #1

    Thread Starter
    Frenzied Member SomethinCool's Avatar
    Join Date
    Jan 2001
    Location
    Malvern, PA
    Posts
    1,407

    Talking Win32

    If you make a form in the resource editor thing named IDD_FORMSHOW, how do you tell the form to be visible in the int main function?

  2. #2
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    I could show you how to do it through pure API
    My evil laugh has a squeak in it.

    kristopherwilson.com

  3. #3

    Thread Starter
    Frenzied Member SomethinCool's Avatar
    Join Date
    Jan 2001
    Location
    Malvern, PA
    Posts
    1,407
    Yeah but i am not ready for that yet...i'm trying to start out very slowly...go with the easy way first...so how do I make the form visible?

  4. #4
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    I've never used MFC but possible the ShowWindow() API would work. But you'd need to have the hWnd of your window for that to work.

    Instead of using int main(), you might have to use int WINAPI WinMain(). Not sure though.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  5. #5
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Using resource dialogs

    I think that is what you are looking for.

    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  6. #6

    Thread Starter
    Frenzied Member SomethinCool's Avatar
    Join Date
    Jan 2001
    Location
    Malvern, PA
    Posts
    1,407
    Yeah i meant WinMain..um...and i tried the showwindow, but i didnt know how to pass the hWnd...

    I'll check out that site, thanks.

  7. #7

    Thread Starter
    Frenzied Member SomethinCool's Avatar
    Join Date
    Jan 2001
    Location
    Malvern, PA
    Posts
    1,407
    when i use that example:
    Code:
    #include <windows.h>
    #include "resource.h"
    
    HWND ghWnd_Main = 0;
    
    INT_PTR CALLBACK DlgProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) {
    	switch(uMsg) {
    		case WM_COMMAND:
    			if(LOWORD(wParam) == IDC_BTN_CANCEL) {
    				MessageBox(hWndDlg, "Cancel pressed!", "Button", MB_OK);
    			}
    			if(LOWORD(wParam) == IDC_BTN_OK) {
    				MessageBox(hWndDlg, "OK pressed!", "Button", MB_OK);
    			}
    			return FALSE;
    
    		case WM_CLOSE:
    			EndDialog(hWndDlg, 0);
    			PostQuitMessage(0);
    			break;
    	}
    	return FALSE;
    }
    
    int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
    	if((ghWnd_Main = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_MAIN), NULL, DlgProc)), ghWnd_Main) {
    		ShowWindow(ghWnd_Main, nCmdShow);
    	} else {
    		MessageBox(NULL, "Could not create dialogue box", "Error", MB_OK);
    	}
    
    	MSG msg;
    	int lRes;
    	for(;;) {
    		lRes = GetMessage(&msg, NULL, NULL, NULL);
    		if(lRes == 0 || lRes == -1)
    			break;
    		DispatchMessage(&msg);
    	}
    	return msg.wParam;
    }


    it keeps saying this error:
    C:\downloads\RawDlg\rawdlg.cpp(26) : error C2664: 'CreateDialogParamA' : cannot convert parameter 4 from 'long (struct HWND__ *,unsigned int,unsigned int,long)' to 'int (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)'
    None of the functions with this name in scope match the target type
    Error executing cl.exe.
    what do i do?

  8. #8
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    That's my code there, so you'd need the Platform SDK installed...

    Either that, or change the INT_PTR to LRESULT...
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width