Thread: Diff between window controls and dialog controls

  1. #1
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584

    Diff between window controls and dialog controls

    When I create a child window control on the parent window (not a dialog), it looks Windows 3.1ish. Basic-like controls. Why is this? Are controls meant to be on dialogs (where they look normal)? Do you understand my question? It is hard to explain...
    1978 Silver Anniversary Corvette

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    Should be the same on window or dlg.

    What type of ctrl?

    If Treeview, Listview ect will need to InitCommonControlsEx() or InitCommonControls()

    Or it could be the styles (or lack of) that is causing this.
    "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
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    I created an edit child window control. It just had a single black line border (put there in the CreateWindow with WS_BORDER). So, it was just a thin black border and a place to write in. Why the primitiveness of the control? Thanks...
    1978 Silver Anniversary Corvette

  4. #4
    Registered User
    Join Date
    Dec 2001
    Posts
    70
    You must assign WS_EX_CLIENTEDGE to dwExStyle argument when creating window of "Edit" class. Background brush should be (HBRUSH) GetStockObject (LTGRAY_BRUSH) for parent window class. Also Give WS_DLGFRAME to the parent window.

    Dialog box creation procedure gives WS_EX_CLIENTEDGE style to the edit control by default, whereas for normal window you must specify this parameter manually.

    Hope this cleared everything.

  5. #5
    Registered User
    Join Date
    Aug 2001
    Posts
    223

    created controls

    also remember to change the font for your control.... that monotype font that comes by default is uuuugly......

    CDC* pdc = m_edtWindow.GetWindowDC();
    m_fontDefault.CreatePointFont( 100, "Times New Roman", pdc);
    pdc->SelectObject( &m_fontDefault );

    m_edtWindow.SetFont( &m_fontDefault );
    zMan

  6. #6
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584

    Re: created controls

    Originally posted by zMan
    also remember to change the font for your control.... that monotype font that comes by default is uuuugly......

    CDC* pdc = m_edtWindow.GetWindowDC();
    m_fontDefault.CreatePointFont( 100, "Times New Roman", pdc);
    pdc->SelectObject( &m_fontDefault );

    m_edtWindow.SetFont( &m_fontDefault );
    Thanks, but I'm not doing this in MFC.

    Thanks, golem, just what I needed! I'm going to try that out right now.
    1978 Silver Anniversary Corvette

  7. #7
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    How would you change the font of control's text (with the API)? Thanks...
    1978 Silver Anniversary Corvette

  8. #8
    LuHa
    Guest
    You have to use the WM_SETFONT message
    SendMessage(hChildControl, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), (LPARAM)FALSE);
    If you don't have the control's handle you can use SendDlgItemMessage. Put lParam == TRUE if you need to redraw the control.

  9. #9
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    Alright, thanks!
    1978 Silver Anniversary Corvette

  10. #10
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    Originally posted by golem
    You must assign WS_EX_CLIENTEDGE to dwExStyle argument when creating window of "Edit" class. Background brush should be (HBRUSH) GetStockObject (LTGRAY_BRUSH) for parent window class. Also Give WS_DLGFRAME to the parent window.

    Dialog box creation procedure gives WS_EX_CLIENTEDGE style to the edit control by default, whereas for normal window you must specify this parameter manually.

    Hope this cleared everything.
    golem, this isn't working. My CreateWindow looks like:
    Code:
    hwndEdit = CreateWindow(TEXT("edit"), NULL,
                WS_CHILD | WS_VISIBLE | ES_LEFT | ES_AUTOHSCROLL | WS_EX_CLIENTEDGE, ... some other parameters);
    It isn't changing the border to 3D or anything. Any help? Thanks...
    1978 Silver Anniversary Corvette

  11. #11
    Unregistered
    Guest
    Don't use CreateWindow use CreateWindowEx instead:


    hwndEdit = CreateWindowEx(WS_EX_CLIENTEDGE,TEXT("edit"), NULL,
    WS_CHILD | WS_VISIBLE | ES_LEFT | ES_AUTOHSCROLL | , ... some other parameters);


    That'll do it. For explicit examples of creating controls:

    http://www.foosyerdoos.fsnet.co.uk

    and for excellent explanations try the forgers tutorials:

    http://www.winprog.org/tutorial/

    Have fun.

  12. #12
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    Try

    WS_EX_OVERLAPPEDWINDOW Combines the WS_EX_CLIENTEDGE and WS_EX_WINDOWEDGE styles

    Check your paint. Could be painting over the edits edge.
    "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

  13. #13
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    Originally posted by Unregistered
    Don't use CreateWindow use CreateWindowEx instead:


    hwndEdit = CreateWindowEx(WS_EX_CLIENTEDGE,TEXT("edit"), NULL,
    WS_CHILD | WS_VISIBLE | ES_LEFT | ES_AUTOHSCROLL | , ... some other parameters);


    That'll do it. For explicit examples of creating controls:

    http://www.foosyerdoos.fsnet.co.uk

    and for excellent explanations try the forgers tutorials:

    http://www.winprog.org/tutorial/

    Have fun.
    Thanks! I'll give this a try.
    1978 Silver Anniversary Corvette

  14. #14
    the Corvetter
    Join Date
    Sep 2001
    Posts
    1,584
    Okay, it worked! Thanks!
    1978 Silver Anniversary Corvette

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WM_CAPTION causing CreateWindowEx() to fail.
    By Necrofear in forum Windows Programming
    Replies: 8
    Last Post: 04-06-2007, 08:23 AM
  2. Edit controls of a dialog from another dialog...
    By Snake in forum Windows Programming
    Replies: 9
    Last Post: 07-01-2005, 02:18 PM
  3. make Child Dialog not Popup?
    By Zeusbwr in forum Windows Programming
    Replies: 5
    Last Post: 04-08-2005, 02:42 PM
  4. confused about adding controls to main window
    By terracota in forum Windows Programming
    Replies: 4
    Last Post: 11-24-2004, 12:35 PM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM