none
How to popup a dialog with win32 api?

    Question

  • I have made a winmain func //hwnd

    In the WinProc:

     case  WM_LBUTTONDOWN:

    CreateWindow()//i just couldn't doing it right

    i wanna to display a dialog just like the MFC DoModal(),

    attention,i will redraw this dialog with button text ect 

    what can i do with win32 API, Anybody can help me,thank u

    Monday, April 25, 2011 8:24 AM

Answers

  • Every post will have a "Mark As Answer" link.

    You can mark multiple posts as answers, because more than one person might have given you the right answer.

    If you feel that you have wrongly marked a post as answer, you can unmark the answer.

     


    «_Superman_»
    Microsoft MVP (Visual C++)

    Polymorphism in C
    • Marked as answer by tripleHHH Monday, April 25, 2011 10:29 AM
    Monday, April 25, 2011 10:21 AM

All replies

  •  

    You can create Dialog using CreateDialog function along with dialog procedure function pointer.

     

    http://msdn.microsoft.com/en-us/library/ms644996%28VS.85%29.aspx#modeless_box


    Thanks and Regards Selvam http://www15.brinkster.om/selvamselvam/
    • Marked as answer by tripleHHH Monday, April 25, 2011 9:50 AM
    • Unmarked as answer by tripleHHH Monday, April 25, 2011 10:29 AM
    Monday, April 25, 2011 9:18 AM
  • Using a dialog template you can use Win32 APIs to create a modal or modeless dialog.

    To create a modal dialog, call the DialogBox API.

    To create a modeless dialog, call the CreateDialog API.

    Here is an example to create a dialog without using a dialog template -

    	g_hWnd = CreateWindowEx(WS_EX_DLGMODALFRAME, "Park", "Park Mouse - Settings",
    		WS_POPUPWINDOW|WS_CAPTION, 0, 0, DLGWIDTH, DLGHEIGHT, 0, 0, hInst, 0);
    
    	g_hTime = CreateWindow("STATIC", 0, WS_CHILD|WS_VISIBLE, 10, 10, 301, 18, g_hWnd, 0, hInst, 0);
    	SetWindowText(g_hTime, "Time :        seconds (Must be more than 1)");
    
    	g_hOK = CreateWindow("BUTTON", 0, WS_CHILD|WS_VISIBLE, 70, 70, 80, 25, g_hWnd, 0, hInst, 0);
    	SetWindowText(g_hOK, "Apply");
     
    	g_hTime = CreateWindow("EDIT", 0, WS_BORDER|WS_CHILD|WS_VISIBLE, 56, 10, 50, 18, g_hWnd, 0, hInst, 0);
    

    The code in the following article has the full example of the above code snippet - http://www.codeproject.com/KB/DLL/ParkMouse.aspx


    «_Superman_»
    Microsoft MVP (Visual C++)
    Monday, April 25, 2011 9:27 AM
  • oh,Great!I'm testing the code,thank you so much SuperMan,you really are!
    Monday, April 25, 2011 9:49 AM
  • Oh,My Godnes ,First time here,biggest mistake i ever made,i confused of the button "Mark As Answer",Sorry superman,Nice to meet u

    Monday, April 25, 2011 9:54 AM
  • If you think my answer is correct you should mark that as the correct answer and not other posts.
    «_Superman_»
    Microsoft MVP (Visual C++)

    Polymorphism in C
    Monday, April 25, 2011 9:55 AM
  • Every post will have a "Mark As Answer" link.

    You can mark multiple posts as answers, because more than one person might have given you the right answer.

    If you feel that you have wrongly marked a post as answer, you can unmark the answer.

     


    «_Superman_»
    Microsoft MVP (Visual C++)

    Polymorphism in C
    • Marked as answer by tripleHHH Monday, April 25, 2011 10:29 AM
    Monday, April 25, 2011 10:21 AM
  • wow,cool...
    Monday, April 25, 2011 10:30 AM