Thread: two Dialog Questions

  1. #1

    Question two Dialog Questions

    I am making a Dialog Based App using the WinAPI and i was wondering how to change the background color of a dialog and also how do i put text into a Rich Edit box manually or using the editor.

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571

    Re: two Dialog Questions

    Originally posted by unanimous
    I am making a Dialog Based App using the WinAPI and i was wondering how to change the background color of a dialog and also how do i put text into a Rich Edit box manually or using the editor.
    Your first question is not easy. There are some really complicated ways of skinning your own dialog box. Check out the Owner Drawn option in the resource editor. Then you'd have to handle all of the WM_PAINT messages and such by yourself. The others ways take way to long to explain, sorry.

    Your next question of how to set text in a rich edit box is pretty simple. Basically, get the handle to the edit box using GetDlgItem then use SetWindowText to change what is in the box.

  3. #3
    Registered User
    Join Date
    Dec 2001
    Posts
    421
    You need to handle the WM_CTLCOLORDLG message in your dialog box procedure.

    Here is a snippet from MSDN:

    The WM_CTLCOLORDLG message is sent to a dialog box before the system draws the dialog box. By responding to this message, the dialog box can set its text and background colors by using the given display device context handle.

    WM_CTLCOLORDLG
    hdcDlg = (HDC) wParam; // handle of dialog box display context
    hwndDlg = (HWND) lParam; // handle of dialog box

    If an application processes this message, it must return the handle of a brush. The system uses the brush to paint the background of the dialog box.

    The system does not automatically destroy the returned brush. It is the application's responsibility to destroy the brush when it is no longer needed.

    The WM_CTLCOLORDLG message is never sent between threads. It is sent only within one thread.

    Note that the WM_CTLCOLORDLG message is sent to the dialog box itself; all of the other WM_CTLCOLOR* messages are sent to the owner of the control.

    If a dialog box procedure handles this message, it should cast the desired return value to a BOOL and return the value directly. If the dialog box procedure returns FALSE, then default message handling is performed. The DWL_MSGRESULT value set by the SetWindowLong function is ignored.
    hope that helps!
    U.
    Quidquid latine dictum sit, altum sonatur.
    Whatever is said in Latin sounds profound.

  4. #4

    Cool Thanks

    Thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 9
    Last Post: 02-13-2008, 02:59 PM
  2. make Child Dialog not Popup?
    By Zeusbwr in forum Windows Programming
    Replies: 5
    Last Post: 04-08-2005, 02:42 PM
  3. Two quick questions about open file dialog boxes
    By PJYelton in forum Windows Programming
    Replies: 5
    Last Post: 04-05-2005, 08:49 AM
  4. Getting the position of a dialog without parent on the screen
    By stormbringer in forum Windows Programming
    Replies: 1
    Last Post: 08-27-2003, 02:59 AM
  5. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM