|
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!
|
|
|
|
|
I need to write some code that kills a process.
I know I can use FindWindow to get the HWND of the window, but how do I get the processID of that HWND?
Does anyone know of a Windows API function that does this?
UPDATE: you can ignore this post, I found the answer, theres a function GetWindowThreadProcessId(), its exactly what I was looking for!
|
|
|
|
|
I have done two classes, CTcpServer and CTcpCLient. I think they are self explained!?
In CTcpServer's Bind() method I get an error when I pass a dotted IP string instead of a DNS. It says "Memory cannot be read" or something...
String is a typedef char*
EndPoint is a structure that looks like this:
struct EndPoint
{
String host;
int port;
}
void CTcpServer::Bind(EndPoint ep) const
{
if(IsSocketOK() == 0)
{
throw CSocketException(WSAGetLastError());
}
EndPoint endpoint = ep;
sockaddr_in config;
config.sin_family = AF_INET;
config.sin_port = htons((u_short)endpoint.port);
if(endpoint.host == NULL)
{
config.sin_addr.S_un.S_addr = INADDR_ANY;
}
else
{
if(inet_addr(endpoint.host) == INADDR_NONE)
{
LPHOSTENT hostentry = gethostbyname(endpoint.host);
config.sin_addr.S_un.S_addr = *((unsigned long*)hostentry->h_addr);
}
else
{
String ip = inet_ntoa(*(LPIN_ADDR)*(endpoint.host));
config.sin_addr.S_un.S_addr = inet_addr(ip);
}
}
if(bind(m_ServerSocket, (sockaddr*)&config, sizeof(config)) != 0)
{
throw CSocketException(WSAGetLastError());
}
}
I want it possible to write either a DNS or dotted IP.
What is wroooong!!!
I'm tired, good night!
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
I do it like this and i dont have any problems passing IP or DNS names..
hostent *pHost = gethostbyname(strDns);
if ( pHost != 0 )
{
sockaddr_in addr;
memset( &addr, 0, sizeof(addr) );
addr.sin_family = AF_INET;
memcpy( &addr.sin_addr, pHost->h_addr, pHost->h_length );
strAddress = inet_ntoa(addr.sin_addr);
}
|
|
|
|
|
So if pHost == 0 there is IP in dotted format?
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
Greetings,
I have a program in which I spawn a process (AcroRd32.exe with the proper parameters) and I want to wait until it has finished writing a file and then close the process. (I am "printing" to a file.)
I know that I can poll the file's size and wait for it to stop growing for some arbitrary time, but this is unsatisfactory for obvious reasons. It seems like the OS knows when a file gets opened and when the file handle is closed. Is there an easy way, given the full pathname to the file, to detect when a file handle gets closed?
I vaguely recall that there was some Win32 API that might help do this but I cannot find it. I really have searched for it, but I guess I'm not using the right keywords!
Thanks for any pointers.
-- Harold
|
|
|
|