|
When i use splitters in my application it is not closed but keepon running in back.i have toclose it by the task manager. when the code of splitter windowis commented off.It works fine.What should I do?
That was my previous message.but as i have been told that i should check for WM_CLOSE message.It is sent.In OnClose() function i wrote
{
if (CFrameWnd::DestroyWindow()!=0)
{
AfxMessageBox("Error",MB_OK);
::DestroyWindow(GetSafeHwnd());
DWORD ErrorCode=GetLastError();
}
}
This ErrorCode has the value 1400,i.e. Invalid window handle,What should i do?
|
|
|
|
|
Hello,
you should NOT destroy the window maually! your applications takes care of that. Thats the reason why it works when you make comment of your code. Let's take a look on how a window is destroyed.
When a WM_CLOSE message arrives, the following functios are called in this order:
OnCloseQuery()
OnClose()
// then the WM_SHOWWINDOW with wParam or lParam set to FALSE is posted
OnHide()
// then the WM_DESTROY is posted
OnDestroy()
In all these functions the window is still there on the heap! You can see the OnDestroy() function as an addition to the destructor of the window.
So what you should do is the following: Get the handle of your splitter window and post the WM_QUIT message, WM_SHOWWINDOW and the WM_DESTROY. This should do the trick.
Please let me know...
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
OUCH!
You should never, ever, post WM_QUIT directly. You should only ever call PostQuitMessage . WM_QUIT is synthesised by GetMessage from the 'quit' flag on the message queue. Once this flag is set, GetMessage will never return another message.
In an MFC application, the quit message is automatically posted by OnNcDestroy if you destroy your thread's main window - the window pointed to by m_pMainWnd in the CWinThread object for the thread. For your main thread, the CWinThread object is the CWinApp -derived object.
You should check to see if you're inadvertantly catching WM_NCDESTROY for your frame window and not passing it down to CWnd . Alternatively, check that you're assigning to m_pMainWnd in your CWinApp::InitInstance override.
|
|
|
|
|
I never said how to post the WM_QUIT message... anyway, if you use PostQuitMessage(), are the other messages (WM_SHOWWINDOW, WM_DESTROY) posted automatically?
thanks
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
No. WM_QUIT is the last message you will ever get.
However, it's the one responsible for breaking out of the GetMessage loop in CWinThread::Run , which is what causes CWinThread to call ExitInstance , and eventually returns from the thread's entry point function.
|
|
|
|
|
So the other 'message' handlers I described won't get called?
Maybe I should quit school if they are teaching me things that aren't even true...
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
Function CreateSemaphore can generate a semaphore
As to anythings else I know very little
Can you tell me where better to programme by adopting semaphore
and the way
Thanks
|
|
|
|
|
Semaphore is an synchronization element, like event, critical section or mutex - elements used in multithreaded programming. You can look to MSDN for detailed description (see CreateSemaphore function).
|
|
|
|
|
Yeah
That is a good idea
and also
note: there are many perfect articles in this site
Maybe that can help us to master "semaphore"
Thank you again!
|
|
|
|
|
Please Help!!!
It is necessary to turn DIB Bitmap on a corner of 90 and 180 degrees
|
|
|
|
|
you can use BitBlt to mirror a bitmap
Don't try it, just do it!
|
|
|
|
|
Hi
I heard a lot about accessing any computer if it is connected via the Internet. So I’m worry about the secret information in my computer ! especially when every one say that WinXP have more problem in Security !
Could any one tell me please how this is possible even if I did not make any share folder on my computer ?
Dose any one know a good articles about this subjects ?
Thanks very much
|
|
|
|
|
wrong section, doesn't have anything to do with visual c++!
Don't try it, just do it!
|
|
|
|
|
I actually use a CTreeView. The selection of HTREEITEMs is made with the mouse.
i want to fordid the use of the key-up, key-down, key-left and key-right which actually allow the selection in the Tree... if someone could hele me
Frackasse
|
|
|
|
|
Handle the TVN_KEYDOWN message.
Arjan.
|
|
|
|
|
Hi,
I created a resource-only Dll to store string, dialog, icon and bitmap. With loadstring function i can load a string from this dll, but i don't know how dipslay a dialog from it. here is my code :
UINT CDataResource::GetResourceDialog(int ResourceID)<br />
{<br />
LPCDLGTEMPLATE lpDialogTemplate = NULL;<br />
HGLOBAL hDialogTemplate = NULL;<br />
HINSTANCE hInst = AfxFindResourceHandle(MAKEINTRESOURCE(ResourceID), RT_DIALOG);<br />
HRSRC hResource = ::FindResource(hInst, MAKEINTRESOURCE(ResourceID), RT_DIALOG);<br />
hDialogTemplate = LoadResource(hInst, hResource);<br />
if (hDialogTemplate != NULL)<br />
lpDialogTemplate = (LPCDLGTEMPLATE)LockResource(hDialogTemplate);<br />
else<br />
return 0;<br />
<br />
ASSERT(lpDialogTemplate != NULL);
// HERE I WANT TO DISPLAY MY DIALOG
<br />
UnlockResource(hDialogTemplate);<br />
FreeResource(hDialogTemplate);<br />
<br />
<br />
<br />
<br />
return 1;<br />
}<br />
Thanks in advance
|
|
|
|
|
hm... It is about 4 years ago, that I did it...
I had the same ressource IDs in the main App AND in the DLL,
but in different languages.
I guess, you can do it like this:
HINSTANCE hDLL = AfxLoadLibrary("ress.dll");
HINSTANCE hRes = AfxGetRessourceHandle();
AfxSetRessourceHandle(hDLL);
//now do your dialog stuff..
AfxSetRessourceHandle(hRes);
AfxFreeLibrary(hDLL);
|
|
|
|
|
Cheickna wrote:
// HERE I WANT TO DISPLAY MY DIALOG
CYourDialogClass dlg;
dlg.InitModalIndirect(lpDialogTemplate);
dlg.DoModal(); Hope this helps,
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
hi there
sorry for this question and dont kill me thanks
(at the moment i work on pocket pc - so there are missing some desktop mfc stuff - but i think its a generally c++ question)
i want to read a file line by line. is it a "good" way to read only once char at time and check for a \n? or is there are more "professional" way to do it?
e.g. this dummy code:
CFile file;
file.Open( L"\\file.txt", CFile::modeRead );
BYTE w[1];
CString s;
while( file.Read( &w, 1 ) != 0 )
{
if( w[ 0 ] == '\n' )
{
MessageBox( NULL, s, NULL, NULL );
s = "";
}
else
{
s.Insert( s.GetLength(), w[0] );
}
}
file.Close();
|
|
|
|
|
<br />
try<br />
{<br />
CStdioFile File("MyFile.txt",CFile::modeRead|CFile::typeText);<br />
<br />
CString strBuf;<br />
bool bNotEOF;<br />
<br />
bNotEOF = File.ReadString(strBuf);
<br />
while ( bNotEOF ) <br />
{<br />
bNotEOF = File.ReadString(strBuf);
}<br />
File.Close();
}<br />
catch(...)<br />
{<br />
::AfxMessageBox("some error");<br />
}<br />
<br />
hope this helps
|
|
|
|
|
i found a nearly similar code too ... but there is one problem:
error C2039: 'ReadString' : is not a member of 'CStdioFile'
on pocket pc the readstring method isnt available
also "getline" + some iostream functions are not available
|
|
|
|
|
If you look at the implementation of GetLine() of a similar function, you'll notice that it reads from the file character by character until EOF or '\n' is encountered! So what you can do is write your own getline .
Tip, one of the parameteres should be the length of the buffer you are putting the characters in, this helps avoiding problems.
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
|
You could also try using fscanf, which includes a format parameter, and you can specify that the scan reads up to but not including a set of characters. (From memory, check the docs) ...
fscanf (fileptr, "%^['\n']s, &buf);
The format specifier is essentially %s, but in between the % and the s is the "up to but not including this list of chars ... the newline."
Dave
"You can say that again." -- Dept. of Redundancy Dept.
|
|
|
|
|
Hi
I've write some strings into the registry by using 'WriteProfileString()'.
Like this (in the registry):
MYPROGRAM
|
|-- EMPLOYEE
|
|
Name: Jens
Salary: 3Million Euro
Birthdate: .....
etc
Now i want to delete the entire section ("employee"). How can i achieve this?
Greetings
Jens
|
|
|
|