CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9

Thread: Creating FORMVIEW WIN32 style app: How to place Formview Resource in the Mainform

Threaded View

  1. #1
    Join Date
    Jun 2004

    Creating FORMVIEW WIN32 style app: How to place Formview Resource in the Mainform

    Hi Guys and Gals,

    Im an MFC guy who mostly writes Desktop FormView apps. in MFC: Not exprienced in WIN32api's

    I'm trying to create a WIN 32 api FormView sytle app, which enventually I will port into classes to automate creating the Win 32 app.

    I'm not very experienced with WIN32s and I'm finally taking the time to learn to write WIN32 apps, hopefully as quick as I can write FormView Apps in MFC.

    Here are my questions:

    1) is there a way to place a formview resource created in the resource editor in the MainForm: like you do in an MFC FORMVIEW? Too cubersome to enter the controls manually as in the code below

    2) In the code below why cant I create the controls in the WM_CREATE message handler: It seems to me that would be the place to do it. I created the on the InitInstance function provided by the Win32 skeleton provided by Visual Studio.

    Here is the Initinstance of my WIN32 App.

    BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
       HWND hWnd;
       hInst = hInstance; // Store instance handle in our global variable
       hWnd = CreateWindow(szWindowClass, //class name
    	  szTitle, 	          //title
          CW_USEDEFAULT,   //x
    	  0,               //y
    	  CW_USEDEFAULT,   //width
    	  0,               //height
    	  NULL,            //parent handle
    	  NULL,            //menu handle
    	  hInstance,       //which program
    	  NULL);           // no init data ? 
       if (!hWnd)
          return FALSE;
       g_hbrBackground = CreateSolidBrush(RGB(0, 0, 0));
       static HWND hwnd_st_u, hwnd_ed_u;
       int x, w, y, h;
       y = 10; h = 20;
       x = 10; w = 50;
       hwnd_st_u = CreateWindow("static", "ST_U",
                                  WS_CHILD | WS_VISIBLE | WS_TABSTOP,
                                  x, y, w, h,
                                  hWnd, (HMENU)(501),
                                  (HINSTANCE) GetWindowLong (hWnd, GWL_HINSTANCE), NULL);
       SetWindowText(hwnd_st_u, "User:");
       x += 5+ w; w = 60;
       hwnd_ed_u = CreateWindow("edit", "",
                                  WS_CHILD | WS_VISIBLE | WS_TABSTOP
                                  | ES_LEFT | WS_BORDER,
                                  x, y, w, h,
                                  hWnd, (HMENU)(502),
                                  (HINSTANCE) GetWindowLong (hWnd, GWL_HINSTANCE), NULL);
       SetWindowText(hwnd_ed_u, "Bill");
       y= 10 + h;
       w = 200;
       HWND hWndEdit = CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("Edit"), TEXT("Enter some text"),
                                   WS_CHILD | WS_VISIBLE, x, y, w,
                                   h, hWnd, (HMENU)(500), NULL, NULL);
       ShowWindow(hWnd, nCmdShow);
       return TRUE;
    Last edited by ADSOFT; January 2nd, 2019 at 04:20 AM.
    Rate this post if it helped you.

Posting Permissions

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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)