|
If you want to capture a button being pressed, you would handle the BN_CLICKED message for that control within the dialog that holds it.
Alex
|
|
|
|
|
Hi.. I'm using a project whose baseclass is CFORMVIEW..
my question is HOW DO YOU CHANGE the COLOR of the FORM???
Thanks...
|
|
|
|
|
OnEraseBackground. Draw the colour you want here instead.
Alex
|
|
|
|
|
Hi ...
Sorry to ask you once again ...but I don't seem to understand your response.
Is this OnEraseBackground a windows message handler .. and where should I add such windows message handler (I only saw WM_ERASEBKGND on the CMainFrame)? And what's the command to change the color of the Form? Please, elucidate.
Thanks for the help. =)
|
|
|
|
|
I've just had a look, and the view *does* have WM_ERASEBKGND. There is no command, this is called whenever the area is erased and you will need to draw the background.
Something like this:
CRect rc;
GetClientRect(&rc);
pDC->FillSolidRect(&rc, RGB(255,0,0));
Alex
|
|
|
|
|
Oh.. didn't see that there was WM_ERASEBKGND.. coz the filter messages was to the default class:VIEW class instead of the window or child window.. so i didn't see it...
alex, thanks a lot...ciao...
|
|
|
|
|
Erasebackground will not completly solve your problem nor do I think it is the prefered method. Usesomething like this:
void CMainView::OnPaint()
{
CMainFrame* pFrame;
CPaintDC dc(this); // device context for painting
pFrame = (CMainFrame*)GetParentFrame();
CString s="Printing Library Demo Program";
pFrame->SetWindowText(s);
RECT rc;
CBrush cBr(RGB(255,255,0));
GetClientRect(&rc);
dc.FillRect(&rc, &cBr);
}
then to solve the control background problem use this:
HBRUSH CMainView::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CFormView::OnCtlColor(pDC, pWnd, nCtlColor);
if(nCtlColor==CTLCOLOR_STATIC)
{
HBRUSH hbr2=CreateSolidBrush(RGB(255,255,0));
pDC->SetBkMode(TRANSPARENT);
return hbr2;
}
return hbr;
}
Class wizard will make both overrides for you
Richard
ISS Software
Dallas Texas
|
|
|
|
|
I posted a message HERE a few days ago, but I have been unable to figure out a solution. I was hoping maybe you GURU's may have some helpful thoughts. The basic situation is as follows...
I have SDI formview based app. It runs fine when compiled in debug mode, and compiles fine in release mode. However, the release version, crashes before reaching the first line of CMyApp::InitInstance() when I attempt to run it. Turning off optimizations doesn't help and I am out of ideas on what to try next.
When I attempt to run to cursor on the first line of InitInstance, the debugger stops in "\Mfc\Src\Appmodul.cpp" on the following function.
extern "C" int WINAPI
_tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
return AfxWinMain(hInstance, hPrevInstance, lpCmdLine, nCmdShow);
}
When I press I run after that it pops up "Unhandled exception in MyApp.exe: 0x0000005: Access Violation", and the debug window, after I stop debugging, shows "First-chance exception in LU.exe (KERNEL32.DLL): 0xC0000005: Access Violation."
Any ideas, thoughts would be greatly appreciated.
- John
|
|
|
|
|
Do you have any static objects in your program? Or, is there any code in CYourApp constructor?
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
No code in the constructor.
|
|
|
|
|
Check wether release version of this app links all other libraries in release version.
Furthermore - try to turn off incremental linking. I have one project which does not want to run (though this is the debug version which does not want to get up - release runs fine) if inremental linking is on...
|
|
|
|
|
All libraries are linked. I tried both using mfc in both a static and shared dll. I tried with and without incremental linking. Still broke. I seem to crash on "ProcessShellCommand(cmdInfo)".
|
|
|
|
|
Mukkie might have a point - plus you are running a unicode based app...
The only KERNEL32 routine that I can see if I break where you indicate is in BaseProcessStart@4. Since a DLL I'm implictly linking to loads before I hit _tWinMain, I'm starting to suspect a DLL.
Hmmm... maybe its an errant MFC dll - try a static link to mfc? I saw a situation once where an install left MFC dlls in the system dir on NT - hiding the proper ones that were in system32.
|
|
|
|
|
How do you tell what is a KERNEL32 routine? And what within "ProcessShellCommand(cmdInfo)" calls routines within KERNAL32?
|
|
|
|
|
Ok, here's the latest. By the suggestion from someone on the previous thread, I started throwing 5 bazillion message boxes everywhere, ie AfxMessageBox("POSITION 1") to see where I was REALLY getting. It turns out debugging the release version doesn't work to well because you can't go line by line. And I found that I crash when ParseCommandLine(cmdInfo); is called from InitInstance(). I found using the debug version, that the MainFrame constructor is called from somewhere within the calls in ParseCommandLine(). So, I assumed I had some variable initialization problem. I initialized every single variable in the constructor, but that didn't seem to help.
|
|
|
|
|
It turns out debugging the release version doesn't work to well because you can't go line by line
Do you enable debug info in the release build? On the C++ tab, general category, select program database for debug info. On the link tab, select generate debug info - you should be able to start with F10 and step through your code...
|
|
|
|
|
Ahh, thanks, I didn't have the program database selected.
The error occurs on the call "ProcessShellCommand(cmdInfo)"
|
|
|
|
|
Are you passing any parameters to the program with the Debug project settings dialog? Perhaps different for the release than those passed for the debug build?
Remember, you can't use fileNothing in an SDI app.
Another thing to watch for (you'll kick yourself) is surrounding code with ASSERT statements - the code just disappears in release, and if its necessary code... BA-BOOM!
Hmmm... maybe you could post your InitInstance code?
|
|
|
|
|
Found solution....or fix anyway.
I believe there is something funny with ON_CONTROL_RANGE message mapping when it is involved with a dialog bar, and a formview app. If I don't use the ON_CONTROL_RANGE message handling, it works fine, so I found a way around it. I had to comment out all my message handlers one by one (well really 50% at a time to narrow it down...etc) to find out where my error occured. I guess that when you call m_wndMyDialogBar.Create(blah blah blah) it creates each of the controls, and then if you have radio buttons like I did, it sets their check value to 0. Thus, it would call the OnCheckMyCoolRadioButton message handler, and it would crash AFTER executing this handler and attempting to return. If you make seperate message handlers for each button, ie ON_BN_CLICKED instead of ON_CONTROL_RANGE, then it works fine.
Finally, DONE!
|
|
|
|
|
Good stuff - one for the books.
Those macros are notorious for introducing 'works in debug but not in release' woes - even without going for ON_CONTROL_RANGE. I noticed that VC7 is much better about catching mismatched fn sigs etc associated with these - actually, its much better at dealing with macros period.
Suggest you ferret away a snapshot of the problem as it was, and compile with VC7 when you get a chance.
Ain't debugging fun, tho?
|
|
|
|
|
Hello All,
I'm looking for an easy way to use multiple file extension in my project. I modified the resource and can get my file open / save dialogs to show a filter for multiple types, ie (txt, c, cpp, h, hpp, etc). However, the shell registration is messed up.
This is my string table entry for IDR_MAINFRAME:
IDR_MAINFRAME "CodeWiz\n\nCodeWiz\nCodeWiz Files (*.uue, *.b64, *.q_p)\n.uue;.b64;.q_p\nCodeWiz.Document\nCodeWiz Document"
This works...as far as adding the multiple extensions to the common dialogs. However, when you call RegisterShellFileTypes, it adds this to explorer:
UUE;.B64;.Q_P
I understand that I have to add multiple doc types (blah, )...but is there an easy way to do this, um...perhaps by registering them manually?
Thanks for any help.
Frank
Allow myself to introduce...myself
- Austin Powers
|
|
|
|
|
Check the MS's KB for Q198538
Ben Burnett
---------
On the topic of code with no error handling -- It's not poor coding, it's "optimistic"
|
|
|
|
|
Thanks Ben!
|
|
|
|
|
i'm searching for a way to show a little image that changes every 2-3 seconds. (It's a small piece of a waveform, like the one in winamp but now in slowmotion )
My knowledge of visual c++/win32 isn't very big so i thought maybe i could get some pointers here..
Should i just create the icon and blit it on my application? or are there better ways to accomplish this ?
thanks in advance,
Fred
btw: i'm not using mfc.
|
|
|
|
|
I think you have to do it by hands
If you can pack the frames up in an animated cursor (with Microangelo or similar program), you can add a ANICURSOR custom resource to your project (VC++ 6.0 will recognize such a type and show it without quotes).
You can load the cursor just like any static cursor, then use DrawIconEx() to draw the frames in a cycle, or in response to a WM_TIMER message.
Be aware that Microangelo saves the .ani file with incorrect RIFF chunk's size, preventing the OS from loading the cursor. You may correct it with any Hex editor: the DWORD at offset 4 should be decremented by 8 (it's chunksize = filesize - 8 )
Paolo
------
"airplane is cool, but space shuttle is even better" (J. Kaczorowski)
|
|
|
|