|
When it comes to Windows programming, often one has to settle for workarounds instead of explanations
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I have a problem using CRecordSet and CDatabase in W2000 with a restricted-permission user. CDatabase::Open return with the error: "Cannot read the registry key SOFTWARE\ODBC\ODBC.INI\ ", but with regedit this key is visible. Where is the problem?
Someone can help me?
thanks
|
|
|
|
|
Greetings all (first post on CodeProject),
Have a fairly simple Dialog based application (modal) which
calls another class (Worker) to perform a list of tasks. Dialog box
class has a simple method for setting the window text of a
CStatic, all works fine (window text is updated correctly
by Worker class until Worker class makes a ShellExecuteEx call
to run another exe. Upon return from the ShellExecuteEx call
the CStatic window text can't be updated, the calls are there
to change the text, it just doesn't work, I've tried a few combinations
of SetForeGroundWindow(), ShowWindow (SW_HIDE/SW_SHOW), Invalidate()
and so on... all to no avail.
Read around various sites and forums with no real success.
Code snipper follows:
if (ShellExecuteEx(&stShellInfo)) {<br />
<br />
int nResult = (int)stShellInfo.hInstApp;<br />
if (nResult >= 32) {<br />
theApp.SetSubProgressMessage("SHELLINFO hInstApp = process successful");<br />
}<br />
else {<br />
theApp.SetSubProgressMessage("Process failed");<br />
}<br />
<br />
WaitForSingleObject(stShellInfo.hProcess, INFINITE);<br />
<br />
CloseHandle(stShellInfo.hProcess);<br />
<br />
CWnd *pWndPrev, *pWndChild;<br />
if (pWndPrev = CWnd::FindWindow(NULL, _T("Progress"))) {<br />
pWndChild = pWndPrev->GetLastActivePopup();<br />
if (pWndPrev->IsIconic()) {<br />
pWndPrev->ShowWindow(SW_RESTORE);<br />
}<br />
<br />
<br />
pWndChild->ShowWindow(SW_HIDE);<br />
pWndChild->ShowWindow(SW_SHOW);<br />
}<br />
...
No message after the "process successful" message are displayed.
Any suggestion/help/info would be greatly appreciated.
BTW, it's probably obvious that I'm new to MFC.
MTIA.
Chris
|
|
|
|
|
Your application sleeps in WaitForSingleObject call until the child process finishes. You need to handle application message queue using PeekMessage. Search in MSDN Library for Q74795 KB article "Using PeekMessage() Loops in a Dialog Box" for details.
Pavel
Sonork 100.15206
|
|
|
|
|
Thanks for the help Pavel, much appreciated.
|
|
|
|
|
Read up on the article you posted, also read about the
TranslateMessage and DispatchMessage functions but still
unclear as to where and how I would implement the
PeekMessage calls.
Once again, many thanks for the help.
Chris
|
|
|
|
|
Use the WaitForSingleObject call in a loop with timeout set to reasonable short time (100 ms?) and when it doesn't return WAIT_TIMEOUT, break from the loop. If it does, pump the messages using PeekMessage and continue looping.
Pavel
Sonork 100.15206
|
|
|
|
|
Hi to All
I want to ask u that how can i make a round shape window or elliptical shape window using MFC.Please explain with some Code
Thanks
Inam
|
|
|
|
|
In your OnCreate handler create a round region then call SetWindowRgn to change the shape of the window like this.
RECT rWindow;
GetWindowRect(&rWindow);
HRGN hRgn = :: Create EllipticRgnIndirect(&rWindow);
::SetWindowRgn(hRgn, TRUE);
You do not need to delete the region that is selected into the SetWindowRgn because windows takes ownership of that region. You should not use that region at all after you call that function.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Hi!
Can windows GDI command be used in the Visual C++?
I'm trying to do some coordinate transformation and mapping in the CView. Can I use windows GDI command such as SetWorldTransformation. It seems like using XForm method were much easier for coordinate transformation. Even if I can use GDI command in my visual C++ project how do I suppose to do it? I've tried the example in MSDN but it didn't work
Newbies
|
|
|
|
|
Zayax wrote:
Can windows GDI command be used in the Visual C++?
In Visual C++ for sure. If you mean in MFC then again, yes. MFC uses CDC class in drawing - it's a thin encapsulation of GDI display context.
Pavel
Sonork 100.15206
|
|
|
|
|
Yes you can, however the wrold translform functions are only supported on the Windows NT operating systems. So your program will not be able to be used on Windows 95, 98 and ME.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Is there any MFC way to do the coordinate transformation?
Newbies
|
|
|
|
|
I do not think that there is. THe reason why is because it would not be supported on Windows 9x.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Then how come there was some software that could do that kind of coordinate transformation and still could be use in win 9x?
Newbies
|
|
|
|
|
The transformations were probably written by hand and did not depend on the Windows API.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
This message continuously scrolls while my project is running and I can't seem to figure out why.
Anyone seen this before?
|
|
|
|
|
You should revise tab order and group styles of buttons in your dialog resource. Radio buttons in one group should be in tab order directly in sequence, first of them should have the Group style set, and the first control behind should have the group style set too.
Pavel
Sonork 100.15206
|
|
|
|
|
Yep that's is it! Thanks...I would have never guessed that the next control would have to have it's group flag set.
Thanks!
|
|
|
|
|
You may get this message anyway, if the radio buttons are the last controls in the tab order in the dialog. It's harmless, so I wouldn't worry about it.
Gary R. Wheeler
|
|
|
|
|
i call
CreatePolygonRgn //rectangle, 4+1 pts
SelectClipRgn
and than
GetClipBox
what returns different coordinates (not in all places but in repeatable situation - there always)
why?
how to transformate Create input to get wanted clipbox?
thanks
t!
|
|
|
|
|
I suspect that the "repeatable situation" is when scrolling occurs.
|
|
|
|
|
repeatable situation is printpreview
no scrolling but different map mode only (aniso)
get returns different scales for x and y and if i see well uncomparable to any view ones
t!
|
|
|
|
|
|
Is there any way to tell when a notebook has been unplugged from the network? Windows 2000 and XP must know this as a balloon tooltip comes up and tells you that the machine has been connected/disconnected from the network.
Thanks for any help you can provide.
Steve.
Systems AXIS Ltd - Software for Business ...
|
|
|
|