|
|
I'm just getting started with windows programming, and am looking for some reliable information on this subject. Is it preferred technique to mix program code written with MFC classes and functions with non-MFC, ordinary C++ windows code? I understand that this can be done, but, I have no experience actually mixing MFC classes with traditional user defined classes and objects. I would appreciate any generalized suggestions, or, citations of specific references. Thanks.
|
|
|
|
|
Yes, you can feel free to use non-MFC classes in your code, especially for code outside the GUI. Note that MFC also provides a number of non-GUI utility classes that you may find useful.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
MFC is just a set of classes that wrap Win32 functionality. You'll NEED to write your own classes in addition to do anything non-trivial with MFC, I would have thought, and to the compiler, there is no real fundamental difference between your classes and Microsofts ( except I trust yours will not leak memory ).
Nebulous Person wrote:
non-MFC, ordinary C++ windows code?
Do you mean C++ *windows* code, or just C++ code ? I'm not sure why you would want to mix Win32 and MFC code, but it can certainly be done.
Christian
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
Ravi Bhavnani and Christian Graus,
Thanks.
|
|
|
|
|
I have an MDI application and need to pop up 2 views on a File -> New operation at all times . I am using the CMDIDocument Template . How do I go about this ?
Thanks and Please help
|
|
|
|
|
<hi guys.
i="" have="" the="" following="" question?
i="" know="" that="" wm_char="" message="" goes="" to="" main="" window="" of="" program="" but="" isn't="" it="" frame?yeah,yeah="" ...="" i="" see="" this="" is="" cview="" where="" exactly="" coded="" in="" mfc?
and="" if="" try="" "go="" round"="" doc="" view="" and="" do="" something="" like=""
m_pmainwnd="new" cmainframe
m_pmainwnd-="">ShowWindow(..)
m_PMainWnd->UpdateWindow()
who gets WM_CHAR ?
10x in advance
|
|
|
|
|
atanas wrote:
who gets WM_CHAR ?
Whoever has a ON_WM_CHAR() Message Map in place and the Wnd has focus.
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
Yeah that sounds right...
But when I try to set the focus to m_pMainWnd
in InitInstance with m_pMainWnd->SetFocus() I still don't get
WM_CHAR in the frame window ?
Can u help?
|
|
|
|
|
So you've checked with Spy++ or WinSpector to see if the WM_CHAR is actually getting to your window right?
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
Yeah I tried both with Spy++ and
Breakpoing but I never saw WM_CHAR for framewnd
|
|
|
|
|
Well it sounds like it doesn't have focus or something is preventing WM_CHAR from getting through. Are you seeing WM_KEYDOWN, WM_KEYUP in Spy++??
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
Yes I see them but they go to the CView window...
Even when I change the focus to the frame window they still go there (to CView window)
|
|
|
|
|
atanas wrote:
Yes I see them but they go to the CView window...
Even when I change the focus to the frame window they still go there (to CView window)
Put TRACE statements in your CView::OnSetFocus() and CView::OnKillFocus() and you will probably find the View has focus, even though you think the MainFrame does.
Why do you want to get at keystrokes in your MainFrame anyway.
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
Ah ...
Thanx Neville now I understand it.
MFC always switch the focus to CView and that's why my WM_CHAR never goes
to MainFrame.
I don't have a particular reason to get the keys in MainFrame...
I just start lerning MFC and I was wandering why CView but not MainFrame gets
WM_CHAR
Well 10x again for the help
|
|
|
|
|
The MFC Framework is a large and reasonably complex beast. Document/View is great stuff, but sometimes you have to fight with it to do what you want.
If you do need to get keys in your MainFrame then use CMainFrame::PreTranslateMessage(). That's what I do in ED (see sig).
atanas wrote:
Well 10x again for the help
I'm glad we got there in the end.;)
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
Hi
I write a sound (*.wav) file, but when I want to play the file with sndPlaySound I get a little blurp from the PC speaker. The particuler file is played with other applications, and other files play fine in my program. The file is closed before I play it. What is wrong?
|
|
|
|
|
what options are you using?
you can also try the PlaySound function
|
|
|
|
|
Joshua Nussbaum wrote:
what options are you using?
??
I've tried PlaySound, same effect.
|
|
|
|
|
what are you sending as the second parameter to sndPlaySound?
|
|
|
|
|
Joshua Nussbaum wrote:
what are you sending as the second parameter to sndPlaySound
at the moment it's:
sndPlaySound("c:\\myKlanke\\DieSin.wav",SND_NOSTOP | SND_ASYNC);
|
|
|
|
|
have you tried it with just SND_ASYNC?
or try SND_SYNC
|
|
|
|
|
Joshua Nussbaum wrote:
have you tried it with just SND_ASYNC?
or try SND_SYNC
just tried both, still same result. Maybe I should just try different flag settings...?
|
|
|
|
|
can you run your code on a different computer, just to illiminate the possiblity of a hardware or driver issue.
|
|
|
|
|
Can that really be an issue? I need sndPlaySound to work on this computer!
|
|
|
|