Click here to Skip to main content
15,887,214 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Overloading operator== for custom class and NULL? Pin
yashachan25-Apr-10 5:16
yashachan25-Apr-10 5:16 
GeneralRe: Overloading operator== for custom class and NULL? Pin
Saurabh.Garg25-Apr-10 5:34
Saurabh.Garg25-Apr-10 5:34 
QuestionAdding items to the title bar Pin
hans.sch24-Apr-10 8:18
hans.sch24-Apr-10 8:18 
AnswerRe: Adding items to the title bar Pin
KingsGambit24-Apr-10 8:36
KingsGambit24-Apr-10 8:36 
GeneralRe: Adding items to the title bar [modified] Pin
hans.sch24-Apr-10 9:03
hans.sch24-Apr-10 9:03 
GeneralRe: Adding items to the title bar Pin
Emilio Garavaglia24-Apr-10 10:40
Emilio Garavaglia24-Apr-10 10:40 
GeneralRe: Adding items to the title bar Pin
hans.sch24-Apr-10 15:10
hans.sch24-Apr-10 15:10 
AnswerRe: Adding items to the title bar (solved) [modified] Pin
hans.sch17-Jun-10 21:30
hans.sch17-Jun-10 21:30 
Thanks to all who helped me. I finally found a solution.

1. Insert the ON_WM_NCPAINT() macro into the dialog's message map, and create an overwritten OnNcPaint method.
2. In OnNcPaint, first call the derived OnNcPaint method, then get the paint DC by calling GetWindowDC(), and paint into the DC whatever you want to paint. That's it.

It is a good idea to exit the function before painting if IsWindowVisible() returns false, or if IsIconic() returns true, because there is no visible title bar to paint on.

If you don't want to paint over the close, minimize, etc. icons, you can retrieve their positions by calling GetTitleBarInfoEx. This function is unfortunately not defined in CWnd, so you must define it as
BOOL GetTitleBarInfoEx(HWND hWnd, PTITLEBARINFOEX pstInfo)
{
    return ::SendMessage(hWnd, WM_GETTITLEBARINFOEX, 0, (LPARAM)pstInfo);
}

GetTitleBarInfoEx will return FALSE unless running Vista and up, so you must check its return value and call GetTitleBarInfo if the call to GetTitleBarInfoEx is not successful. GetTitleBarInfo is a member of CWnd Smile | :)

If you want to put a flashlight on the title bar, create a timer event which changes a flag (which indicates whether the light is on or off) and then calls RedrawWindow(NULL, NULL, RDW_FRAME | RDW_INVALIDATE);. This will post the WM_NCPAINT message.

What I wrote is for CDialog derived classes. I read (but I haven't tried it) that for MDI applications, you must insert this functionality into the main frame.

modified on Friday, June 18, 2010 3:50 AM

QuestionHow to avoid Buffer Overrun?! Pin
Fareed Rizkalla24-Apr-10 7:38
Fareed Rizkalla24-Apr-10 7:38 
AnswerRe: How to avoid Buffer Overrun?! Pin
Rajesh R Subramanian24-Apr-10 7:41
professionalRajesh R Subramanian24-Apr-10 7:41 
AnswerRe: How to avoid Buffer Overrun?! Pin
Moak24-Apr-10 9:06
Moak24-Apr-10 9:06 
AnswerRe: How to avoid Buffer Overrun?! Pin
Saurabh.Garg24-Apr-10 17:55
Saurabh.Garg24-Apr-10 17:55 
AnswerRe: How to avoid Buffer Overrun?! Pin
RedZombie12527-Apr-10 16:45
RedZombie12527-Apr-10 16:45 
QuestionCan I get a FILE* from a HANDLE? Pin
sashoalm24-Apr-10 5:59
sashoalm24-Apr-10 5:59 
AnswerRe: Can I get a FILE* from a HANDLE? Pin
sashoalm24-Apr-10 6:16
sashoalm24-Apr-10 6:16 
AnswerRe: Can I get a FILE* from a HANDLE? Pin
«_Superman_»24-Apr-10 8:04
professional«_Superman_»24-Apr-10 8:04 
QuestionWin32's HttpSendRequest : ERROR_INTERNET_INCORRECT_HANDLE_STATE Pin
VictorSotnikov24-Apr-10 4:12
VictorSotnikov24-Apr-10 4:12 
AnswerRe: Win32's HttpSendRequest : ERROR_INTERNET_INCORRECT_HANDLE_STATE Pin
Luc Pattyn24-Apr-10 4:19
sitebuilderLuc Pattyn24-Apr-10 4:19 
QuestionHelp for RAPI functions. Pin
Le@rner23-Apr-10 22:33
Le@rner23-Apr-10 22:33 
AnswerRe: Help for RAPI functions. Pin
Gary R. Wheeler23-Apr-10 23:49
Gary R. Wheeler23-Apr-10 23:49 
GeneralRe: Help for RAPI functions. Pin
Le@rner24-Apr-10 0:01
Le@rner24-Apr-10 0:01 
GeneralRe: Help for RAPI functions. Pin
Chris Losinger24-Apr-10 9:17
professionalChris Losinger24-Apr-10 9:17 
GeneralRe: Help for RAPI functions. Pin
Tim Craig24-Apr-10 17:06
Tim Craig24-Apr-10 17:06 
QuestionCString to Unsigned short and unsigned short to CString in vc++ Pin
Member 365375123-Apr-10 21:20
Member 365375123-Apr-10 21:20 
AnswerRe: CString to Unsigned short and unsigned short to CString in vc++ Pin
Richard MacCutchan23-Apr-10 21:39
mveRichard MacCutchan23-Apr-10 21:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.