I'm working on a little app and this is the first time I'm coding using MFC and VC++.
I have a CFrameWnd derived main window as well as a CWnd derived child window. I wish to place a CBitmapButton in the child window. I create a CBitmapButton object, call it's create function with WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON | BS_OWNERDRAW but it refuses to show up where I need it to. On the other hand, when I create it in the main window, it shows up with no problem. So essentially, I can't seem to make a visible button (as a child) in the child window of a main window but I seem to be able to do it in the main window.
What is going on? I'll be greatly appreciative of your advice, of course.
That's in CMainChildWnd::OnCreate(LPCREATESTRUCT lpcs).
I repeat, the button is completely invisible. However, it does turn up if I put the very same code in the parent CMainWnd : public CFrameWnd object i.e, in the parent window.
I don't ask you whether it "compiles". Sure it is! Otherwise you couldn't run your App.
I ask you whether this line of code is executed! Set a break point to this line and then start your App from IDE using F5. If it is executed then it would be nide to know what this cbut1.Create(...) returns...
Besides, you have hardcoded the CRect coordinates of the button. But will this rect lie in the client area of CMainChildWnd window?
I don't ask you whether it "compiles". Sure it is! Otherwise you couldn't run your App.
I ask you whether this line of code is executed! Set a break point to this line and then start your App from IDE using F5. If it is executed then it would be nide to know what this cbut1.Create(...) returns...
Besides, you have hardcoded the CRect coordinates of the button. But will this rect lie in the client area of CMainChildWnd window?
I set a breakpoint as you suggested and ran it using F5. I have no idea about this procedure but I made these observations:
1.) It did not break at that line, if that was expected.
2.) It said exactly:
'Temp.exe': Loaded 'C:\Users\Nitin\Documents\Visual Studio 2005\Projects\Temp\debug\Temp.exe', Symbols loaded.
'Temp.exe': Loaded 'C:\Windows\System32\ntdll.dll', No symbols loaded.
'Temp.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', No symbols loaded.
'Temp.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', No symbols loaded.
'Temp.exe': Loaded 'C:\Windows\SysWOW64\user32.dll', No symbols loaded.
'Temp.exe': Loaded 'C:\Windows\SysWOW64\gdi32.dll', No symbols loaded.
'Temp.exe': Loaded 'C:\Windows\SysWOW64\lpk.dll', No symbols loaded.
'Temp.exe': Loaded 'C:\Windows\SysWOW64\usp10.dll', No symbols loaded.
'Temp.exe': Loaded 'C:\Windows\SysWOW64\msvcrt.dll', No symbols loaded.
'Temp.exe': Loaded 'C:\Windows\SysWOW64\advapi32.dll', No symbols loaded.
'Temp.exe': Loaded 'C:\Windows\SysWOW64\sechost.dll', No symbols loaded.
'Temp.exe': Loaded 'C:\Windows\SysWOW64\rpcrt4.dll', No symbols loaded.
'Temp.exe': Loaded 'C:\Windows\SysWOW64\sspicli.dll', No symbols loaded.
'Temp.exe': Loaded 'C:\Windows\SysWOW64\cryptbase.dll', No symbols loaded.
'Temp.exe': Loaded 'C:\Windows\SysWOW64\comdlg32.dll', No symbols loaded.
'Temp.exe': Loaded 'C:\Windows\SysWOW64\shlwapi.dll', No symbols loaded.
'Temp.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.7600.16385_none_ebf82fc36c758ad5\comctl32.dll', No symbols loaded.
'Temp.exe': Loaded 'C:\Windows\SysWOW64\shell32.dll', No symbols loaded.
'Temp.exe': Loaded 'C:\Windows\SysWOW64\winspool.drv', No symbols loaded.
'Temp.exe': Loaded 'C:\Windows\SysWOW64\ole32.dll', No symbols loaded.
'Temp.exe': Loaded 'C:\Windows\SysWOW64\oleaut32.dll', No symbols loaded.
'Temp.exe': Loaded 'C:\Windows\SysWOW64\imm32.dll', No symbols loaded.
'Temp.exe': Loaded 'C:\Windows\SysWOW64\msctf.dll', No symbols loaded.
'Temp.exe': Loaded 'C:\Windows\SysWOW64\uxtheme.dll', No symbols loaded.
'Temp.exe': Loaded 'C:\Windows\SysWOW64\dwmapi.dll', No symbols loaded.
'Temp.exe': Loaded 'C:\Windows\SysWOW64\ole32.dll', No symbols loaded.
'Temp.exe': Unloaded 'C:\Windows\SysWOW64\ole32.dll'
'Temp.exe': Loaded 'C:\Windows\winsxs\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7600.16385_none_421189da2b7fabfc\comctl32.dll', No symbols loaded.
Detected memory leaks!
Dumping objects ->
{84} client block at 0x025A7930, subtype c0, 84 bytes long.
a CPaintDC object at $025A7930, 84 bytes long
Object dump complete.
The program '[1400] Temp.exe: Native' has exited with code 0 (0x0).
3.) It did not trace/output the return value of the Create function at all.
4.) I later checked the "Hit Count" of the breakpoint, which turned out to be 0.
It turns out, and I'm ashamed of myself, that I had the statements after the "return 0;" of the int OnCreate(...)
I'm very grateful to you for having helped me out though, I never really had got around to using the Debugger. This was a learning experience, nevertheless.
Bookmarks