Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

reg buttons in win32


hey everyone,

i wanted to know how cud i create a window with 4 buttons inside it and when the user clicks a button i want to return a number corresponding to it. I want to do this using win32. hope u guyz send in a reply sooon



Comments

  • AsmGuru62AsmGuru62 Member Posts: 6,519
    :
    : hey everyone,
    :
    : i wanted to know how cud i create a window with 4 buttons inside it and when the user clicks a button i want to return a number corresponding to it. I want to do this using win32. hope u guyz send in a reply sooon
    :
    :
    :
    :
    [blue]Make a dialog box with these buttons and when WM_COMMAND will be received call EndDialog() with the specified button ID.[/blue]
  • schumacher1011schumacher1011 Member Posts: 19
    : :
    : : hey everyone,
    : :
    : : i wanted to know how cud i create a window with 4 buttons inside it and when the user clicks a button i want to return a number corresponding to it. I want to do this using win32. hope u guyz send in a reply sooon
    : :
    : :
    : :
    : :
    : [blue]Make a dialog box with these buttons and when WM_COMMAND will be received call EndDialog() with the specified button ID.[/blue]
    :



    : I created a win32 application and added a resource with the buttons on it. Inside the WinMain I call the DialogBox command but it gives me an error if i directly call the Dialog Procedure (4th arguement) but found this code to work

    INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    LPSTR lpCmdLine, int nCmdShow)
    {
    DialogBox(hInstance, MAKEINTRESOURCE(IDD_DLGFIRST),
    hWnd, reinterpret_cast(DlgProc));
    return FALSE;
    }

    Is this the only way ??

    After this,i cud do all the things in the WM_COMMAND of the Dialog procedure.

    Thanks in advance
    schumi

  • Johnny13Johnny13 Member Posts: 128
    where is hWnd? (3rd parameter) try change the call to
    [blue]DialogBox(hInstance,"yourdialog",NULL,DlgProc);[/blue]
  • AsmGuru62AsmGuru62 Member Posts: 6,519
    : : :
    : : : hey everyone,
    : : :
    : : : i wanted to know how cud i create a window with 4 buttons inside it and when the user clicks a button i want to return a number corresponding to it. I want to do this using win32. hope u guyz send in a reply sooon
    : : :
    : : :
    : : :
    : : :
    : : [blue]Make a dialog box with these buttons and when WM_COMMAND will be received call EndDialog() with the specified button ID.[/blue]
    : :
    :
    :
    :
    : : I created a win32 application and added a resource with the buttons on it. Inside the WinMain I call the DialogBox command but it gives me an error if i directly call the Dialog Procedure (4th arguement) but found this code to work
    :
    : INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    : LPSTR lpCmdLine, int nCmdShow)
    : {
    : DialogBox(hInstance, MAKEINTRESOURCE(IDD_DLGFIRST),
    : hWnd, reinterpret_cast(DlgProc));
    : return FALSE;
    : }
    :
    : Is this the only way ??
    :
    : After this,i cud do all the things in the WM_COMMAND of the Dialog procedure.
    :
    : Thanks in advance
    : schumi
    :
    :
    [blue]The procedures you pass into Win32 API as parameters cannot be called directly - they built to be called by Windows.[/blue]
  • schumacher1011schumacher1011 Member Posts: 19
    : where is hWnd? (3rd parameter) try change the call to
    : [blue]DialogBox(hInstance,"yourdialog",NULL,DlgProc);[/blue]
    :


    it gimmes an error saying

    'DialogBoxParamA' : cannot convert parameter 4 from 'long (struct HWND__ *,unsigned int,unsigned int,long)' to 'int (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)'


    I had inserted a dialog as a resource and put 4 buttons on it... and in winmain inserted the code that you had given

    DialogBox(hInstance,"yourdialog",NULL,DlgProc);




  • AsmGuru62AsmGuru62 Member Posts: 6,519
    : : where is hWnd? (3rd parameter) try change the call to
    : : [blue]DialogBox(hInstance,"yourdialog",NULL,DlgProc);[/blue]
    : :
    :
    :
    : it gimmes an error saying
    :
    : 'DialogBoxParamA' : cannot convert parameter 4 from 'long (struct HWND__ *,unsigned int,unsigned int,long)' to 'int (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)'

    [blue]
    You should keep that part:

    [italic]...reinterpret_cast...[/italic]
    [/blue]
    :
    :
    : I had inserted a dialog as a resource and put 4 buttons on it... and in winmain inserted the code that you had given
    :
    : DialogBox(hInstance,"yourdialog",NULL,DlgProc);
    :
    :
    :
    :
    :

  • schumacher1011schumacher1011 Member Posts: 19
    : : : where is hWnd? (3rd parameter) try change the call to
    : : : [blue]DialogBox(hInstance,"yourdialog",NULL,DlgProc);[/blue]
    : : :
    : :
    : :
    : : it gimmes an error saying
    : :
    : : 'DialogBoxParamA' : cannot convert parameter 4 from 'long (struct HWND__ *,unsigned int,unsigned int,long)' to 'int (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)'
    :
    : [blue]
    : You should keep that part:
    :
    : [italic]...reinterpret_cast...[/italic]
    : [/blue]
    : :
    : :
    : : I had inserted a dialog as a resource and put 4 buttons on it... and in winmain inserted the code that you had given
    : :
    : : DialogBox(hInstance,"yourdialog",NULL,DlgProc);
    : :
    : :
    : :
    : :
    : :
    :
    :

    okay thnx a lot dude !!!

Sign In or Register to comment.