recources question

This is a discussion on recources question within the Windows Programming forums, part of the Platform Specific Boards category; How do I embed a dialog-like recource into the main window of a windows app (not just a dialog app). ...

  1. #1
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052

    recources question

    How do I embed a dialog-like recource into the main window of a windows app (not just a dialog app). I have seen it some where but I don't know how he did it.

    Thanks
    Chris
    Please direct all complaints regarding this post to the nearest brick wall Have a nice day.

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,855
    When you say dialog based resource do you mean a single ctrl OR a whole dialog you made in the resource editor?

    For a single ctrl use CreateWindow(), sepecify the HMENU as the ID (#define one) and its msg's will be sent to the callback of the parent HWND param.

    For a dialog, create it and use SetWindowPos() hiding it when not needed. Create it with out the system menu and I would make it a child of the main depending on if it needs a seperate callback.

    Is that what you want?
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  3. #3
    Registered User
    Join Date
    Dec 2001
    Posts
    421
    also, make sure the dialog is modeless!!!
    Quidquid latine dictum sit, altum sonatur.
    Whatever is said in Latin sounds profound.

  4. #4
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    That sounds like the right thing for me, so I searched for SetWindowPos() in the msdn library, but it came up with nothing... Could you please explain it to me?
    Please direct all complaints regarding this post to the nearest brick wall Have a nice day.

  5. #5
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    i just tried again without the '()' and I found it. I'm reading it now and if I have any problems with, i'll post another reply to this thread...
    Please direct all complaints regarding this post to the nearest brick wall Have a nice day.

  6. #6
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    SetWindowPos() doesn't actually have a parameter for the ID of the recource, so how will it know what to place at the specified co-ordinates?
    Please direct all complaints regarding this post to the nearest brick wall Have a nice day.

  7. #7
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,855
    The first param is the HWND of the dialog you want to move

    Say we have a main window (MainHwnd is its HWND)
    On it a frame ctrl or similar has been placed called IDC_FRAME. Or divide up the area as you need.
    Our dialog to place in the frame has DIALOGhWnd returned when we created it.
    Code:
    //find the WHOLE dimensions of the dialog to move
    GetWindowRect(DIALOGhWnd,&DLG_Rect);
    iWidthDlg=DLG_Rect.right-DLG_Rect.left;
    iHeightDlg=DLG_Rect.bottom-DLG_Rect.top;
    //find where to put it in the frame
    FRAMEhWnd=GetDlgItem(hMainWnd,IDC_FRAME);
    GetClientRect(FRAMEhWnd,&FRAME_Rect);
    //place at top left corner of frame
    SetWindowPos(DIALOGhWnd, HWND_TOPMOST, FRAME_Rect.left, FRAME_Rect.top, iWidthDlg, iHeightDlg, 0);
    Should check to see if fits eg iWidthDlg<FRAME_Rect.right-FRAME_Rect.left;
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  8. #8
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    Originally posted by novacain

    On it a frame ctrl or similar has been placed called IDC_FRAME. Or divide up the area as you need.
    How do initially do this?
    Please direct all complaints regarding this post to the nearest brick wall Have a nice day.

  9. #9
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,855
    HWND hDlg;//handle to dialog
    HWND hFrame;//handle to frame ctrl
    #define IDC_FRAME 10001//set up resource ID#
    int iMargin=10;//extra distance from edge of main window (for appearance)

    Code:
    GetWindowRect(hDlg,&DlgRect);//sometimes client rect works better
    //create an invisible frame for the dlg
    hFrame=CreateWindow("Static",NULL,WS_CHILD,
           DlgRect.left+iMargin,DlgRect.top+iMargin,
           DlgRect.right-DlgRect.left+iMargin ,DlgRect.bottom-DlgRect.top+iMargin,
           hwnd,(HMENU)IDC_FRAME,hInst,NULL);
    //set the dlg to the frame and make sure it is on the top and visible
    SetWindowPos(hDlg,HWND_TOPMOST,
           DlgRect.left+iMargin,DlgRect.top+iMargin,
           DlgRect.right-DlgRect.left+iMargin ,DlgRect.bottom-DlgRect.top+iMargin,
           SWP_SHOWWINDOW|SWP_DRAWFRAME);
    Now you have to stop it being moved, but that is another story.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  2. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  3. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  4. Question about linked lists.
    By cheeisme123 in forum C++ Programming
    Replies: 6
    Last Post: 02-25-2003, 12:36 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 12:47 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21