|
I have an MFC application that loads data from a database. I created a user interface thread based on CWinThread that displays a modal dialog with a text box and a cancel button. The user can click the cancel button to abort the load. The load takes place ( and the dialog is created ) in the OnNewDocument handler of the main app. The first time it works perfectly but if I click File New the UI thread gets stuck in the dialog creation code somewhere and the dialog is not displayed. When the load function completes it does a PostThreadMessage to the new thread sending a WM_QUIT message and waits for the UI thread to close. Because the UI thread is stuck it doesn't respond and the application stalls.
Any ideas?
|
|
|
|
|
Hi,
Put a break point @ on new document & Oninitdialog of the dialog and check where it is getting struck. Sometimes the callstack may give you more information regarding the location.
Have a look @ this link on UI Threads it will surely help you
http://flounder.com/uithreads.htm.
This may help you
Sujan
|
|
|
|
|
Make it a modeless dialog instead. Even if you do keep it in the secondary thread.
Then you can just hide and show it, and each time the OnFileNew is called, you won't have to keep trying to create/destroy a window.
|
|
|
|
|
hello...
does any of you have any idea how to hide or close the console window without terminating your whole process? I've been experimenting lately with Win32 console application with MFC support... My rpogram basically communicates with a RAID system through the serial port.
My program is already working fine but I wanted to hide the console window while my program is running. Is there a way to hide the console window and just display my UI?
if any of you have any idea, you can reply to this post or email me personally...
my email add is dimitri_sjp@yahoo.com
thanks !!!
sunrise... sunset... sunrise... sunset... sunrise... sunset...
|
|
|
|
|
You should create Win32 or MFC application to hide console.
ARSALAN MALIK
|
|
|
|
|
megiddo wrote:
...does any of you have any idea how to hide or close the console window...
Which console wiondow?
megiddo wrote:
Is there a way to hide the console window and just display my UI?
If you have a handle to the console window (e.g., GetConsoleWindow() ), just send it a WM_SHOWWINDOW message.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Dear friends,
I want to add "scripting support" in my application. i.e i want the end users to write the code at run time and then i want my application to execute it. I also want to pass the parameters to the scripts and want scripts to call back the methods in my application.
Can anyone tell me what is the best approach to follow ???
Imtiaz
|
|
|
|
|
I just did this by working from the article at
http://www.microsoft.com/mind/0297/activescripting.asp
Good luck...
|
|
|
|
|
hey guys! i have this socket issue... im trying to connect using this command..
pSockCon->Connect("1.1.1.26", 777)... it works fine as i see the output on my socket workbench... but when i try to connect using this... pSockCon->Connect("1.1.1.26", 2103)... it still connects eventhough i stop already my socket workbench from listening to that port.. actually i cant listen with port number 2103 and it says there "operating system reports:10048 Address in use".. whats with the port 2103? is it always active? my program hangs everytime i use the port 2103 coz "Connect" returns always true eventhough my socket workbench isnt listening... pls help me..
|
|
|
|
|
Will anyone explain to me the advantage of one over the other - Passing the reference and passing the poniter as parameter in function calls
|
|
|
|
|
Hi
My understanding is there is not much difference in using reference and pointers for function calls.
Using reference makes the code neat and does the work of a pointer. It comes handy while using operator overloading etc.
Go through this article
http://www.embedded.com/showArticle.jhtml?articleID=9900082[^]
regards
The Best Relligion is Science.
Once you understand it, you will know God.
|
|
|
|
|
The main advantages of references are that they are strongly type-safe, and cannot be NULL. Sometimes, passing NULL is a valid option, so a reference can't be used. Also, references are not suitable for things like data buffers or arrays, where the type of the data is unknown or variable, or the length of the data is variable. For example, a char* can point to one or more characters, but a char& is a reference to a single character.
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"
|
|
|
|
|
I have a function
Swap(int& a, int& b)
Does your statement "Sometimes, passing NULL is a valid option, so a reference can't be used" means that I cannot call Swap(2, NULL)(for eg.)
It will not give any error. I am using MS VC++ 6.0
|
|
|
|
|
Ranjish wrote:
Does your statement "Sometimes, passing NULL is a valid option, so a reference can't be used" means that I cannot call Swap(2, NULL)(for eg.)
Yes, for two reasons. First, you cannot supply a constant literal (2) as a non-constant reference. Second, you cannot pass NULL as a reference. A reference must always refer to an object.
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 Ryan,
I am using MS VC++ 6.0.
The below code will work.
#include <iostream.h>
void Swap(int& a, int& b)
{
a += b;
b = a - b;
a -=b;
}
int main()
{
int x = 2;
int y = NULL;
Swap(x, y);
cout << x << " " << y << endl;
return 0;
}
Is it because of Converting NULL to zero before initialization.
|
|
|
|
|
There's nothing wrong with that code. You're passing x (an int) and y (an int) both as int references, so the code is fine. The contents of the variables don't make any difference, as long as they are variables.
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"
|
|
|
|
|
Will anybody expain to me who calls Main() in Windows and where does main returns. Who uses the return value for wht purose. PLease don't just answer it as OS. I am looking for a detailed answer
|
|
|
|
|
Hi,
Open an appln in VC++ give F11(Step Into) it will open up the APPMODUL.CPP file there you can see _tWinMain
Sujan
|
|
|
|
|
Ranjish wrote:
Will anybody expain to me who calls Main() in Windows and where does main returns
When you say main(), I presume that you're talking about a console app.
When you compile a C/C++ application, it's actually not you main() function which will be invoked first. The C/C++ runtime needs to set up some stuff, like initializing global objects, and then it will invoke main().
When main() exits, or when you invoke exit(), it's actually not the last code to run. Again, the C/C++ runtime needs to clean up eg. by running deallocators for global objects.
Ranjish wrote:
Who uses the return value for wht purose.
If you've started a process using spawnl(), you can use _cwait() to get the result code.
"After all it's just text at the end of the day. - Colin Davies
"For example, when a VB programmer comes to my house, they may say 'does your pool need cleaning, sir ?' " - Christian Graus
|
|
|
|
|
[edit]Missed the ReleaseDC() call... [/edit]
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"
|
|
|
|
|
But I have called : m_pParent->ReleaseDC(pDC);
Do you think it cann't released the pDC actually?
How can I do?
can I use : ::ReleaseDC(m_pParent->m_hWnd,pDC->GetSafeHdc()); it is testing now.
|
|
|
|
|
If ReleaseDC fails to release a DC it returns 0. If it is returning 1 then it is successfully releasing.
You could check for a 0 return value!
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
Strange! Are you sure you have always called ReleaseDC after each call to GetDC and GetWindowDC elsewhere in your application? (Remember to check all possible code paths)
Other than that I would tend to move the ReleaseDC out of the if statement so that it is always called after GetDC is called, no matter what result you have from GetDC.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|
|
there is no ..if.. else ..in the original code ,And I called the ReleaseDC().when i found the problem,I add it . I checked the returned value of ReleaseDC(),it's successful everytime.
I have checked all the GetDC in my programm,it realeased OK.
now i do it as follows:
CDC pDC;
if(pDC.Attach(hDC))
{
pDC.BitBlt(rcClient.left, rcClient.top, rcClient.Width(), rcClient.Height(), &m_dcMap, rcClient.left, rcClient.top, SRCCOPY);
}
else
{
TRACE("\ncann't get parent DC\n");
strTemp = "cann't get parent DC";
((CFMapCtrl*)m_pParent)->WriteLogFile(strTemp);
}
pDC.Detach();
hDC is saved at the initial time.
it seems better.
|
|
|
|
|
Good to hear.
Just a small point. You needn't use a new CDC with Attach and Detach if you use the GDI calls direct.
i.e.
::BitBlt(hDC, rcClient.left, rcClient.top, rcClient.Width(), rcClient.Height(), m_dcMap.GetSafeHdc(), rcClient.left, rcClient.top, SRCCOPY);
This makes the code a little simpler.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fruity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Walliams (Little Britain)
|
|
|
|