|
Hi Stevy,
Have u find answer for this question?. I'm also having the same issue can u please help me.
|
|
|
|
|
I have two dialog: one parent and one child.
Can I get the name (or the class) of the parent from the child?
thanks a lot
|
|
|
|
|
Really I don't Understand what do you want.
if You need to access the class member of parent from
child.
here is solution
In Child Dlg Class ,declare a var which is pointer to
Parent Class.
like this
CParentDlg *m_ParentDlg;
and Function
GetParentWnd(CParentDlg *m_Wnd)<br />
{<br />
m_ParentDlg=m_Wnd;<br />
}
now in Parent Class before calling the Child DLg
pass parent pointer
mChildDlg.GetParentWnd(this);
///call the domodal or showindow
and use m_ParentDlg in your Child class to access info from main parent Dlg
-----------------------------
"I Think this Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Thanks a lot for your answer but i can't use this solution.
I try to explain me better (i don't speak english very well).
I call the same child dialog from two different parent and i need to know wich is the parent in both the cases. Do you understand what i want?
Thanks a lot on more time!
|
|
|
|
|
Well, you could always send a registered message to your parent window and it can respond with a different return value depending upon which one it is.
Or, you can set a global variable containing the parent window's 'type when the parent is created and then the child can read it.
Or you can use GetParent and then call RealGetWindowClass.
There are other ways, but these came to mind pretty quickly.
|
|
|
|
|
CString str;
GetParent()->GetWindowText(str);
TOXCCT >>> GEII power [VisualCalc] | [toxcct]
|
|
|
|
|
|
There are two threads:
//thread_one:
{
HANDLE hEvent=CreateEvent(NULL,TRUE,FALSE,NULL);
SetEvent(hEvent);
// do sth
// ...
AfxBeginThread(thread_two,this);
WaitForSingleObject(hEvent,INFINITE);
// continue to do sth...
}
thread_two:
{
ResetEvent(hEvent);
// do sth
// ...
SetEvent(hEvent);
}
I want thread_one to wait at WaitForSingleObject until thread_two passing SetEvent.
But the fact is thread_one wait at WaitForSingleObject for ever!!
|
|
|
|
|
After CreateEvent the only place you need to do anything with the event is at the end of thread_two. Remove the SetEvent in thread_one and ResetEvent in thread_two. Also make sure that the SetEvent in thread_two really sets the event that the WaitForSingleObject is waiting for. Mind local variable scope. I.e. if you have and event handle in your class called hEvent, and you do:
HANDLE hEvent = ::CreateEvent(NULL, TRUE, FALSE, NULL);
the class (or object really) hEvent (having the same name as above) will not be set and the WaitForSingleObject will wait for a non-initialized event, thus holding execution indefinitely.
Hope this helps.
|
|
|
|
|
The reason I call ReSetEvent is that WaitForSingleObject at thread_one is not always waiting for when thread_two sets the event, so I set the event to nonsignaled state by using ReSetEvent to make sure thread_one should wait at WaitForSingleObject when thread_two is running.
What's wrong with the ReSetEvent function I called could cause 'waiting for ever' ?
BTW. Assume there is no variable scope problem.
Thanks
|
|
|
|
|
Theres no problem per se. But the first reason thread_one is not waiting is because of the SetEvent (after the CreateEvent method). This means that when you get to the WaitForSingleObject, it will just continue right on. So as I said, you should remove it.
The second reason is multithreading. When you start thread_two, don't assume that the ResetEvent in thread_two will get executed before you get to the WaitForSingleObject in thread_one (it is less probable than not that that will ever happen). So this is why thread_one does not wait sometimes, all at the mercy of Windows thread scheduling.
So, remove the SetEvent in thread_one and the ResetEvent in thread_two (optionally of course, because it doesn't do anything) and the code as it stands should work A OK.
|
|
|
|
|
Thanks for help.
But I found sth strange.
When thread_one is waiting at WaitForSingleObject() and at the same time thread_two was also suspended instead of running as I supposed before.
I use a counter in thread_two to caculated how many steps passed by when thread_one is waiting for it, but the fact is that the counter remains the same between WaitForSingleObject(hEvent,1000); that is to say thread_two was suspended when thread_one call WaitForSingleObject, but why????
|
|
|
|
|
That does indeed sound strange. Are you linking with the multithreaded runtime libraries? Because that kind of odd behavior could arise from linking with the single threaded ones.
|
|
|
|
|
Your hEvent in Thread one is a local variable which never gets set. Make it a class member or a global variable and then set that global variable from outside thread one.
Stuck to Programming through an unbreakable bond
My Articles
|
|
|
|
|
How to save the bmp file?
the data is YUYV format.
Give me a sample ,thanks !
could I first convert the data from YUV format to RGB format?
.
|
|
|
|
|
http://www.codeproject.com/bitmap/[^]
Articles:
CxImage // LARGE: handles multiple images formats
CDibData // SMALL: load, save, access (NEEDS UPDATING)
CDIBsectionLite // SMALL: load, save, access
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
hi, i was developing a plug-in for IE regarding image. I'm looking for event handler which will get fired whenever a image is found, or downloaded/loaded, or by user's command.(e.g. by IE itself will display email to fren etc whenever u right click on a image, and only on a image)
may be i can make use of DWebBrowserEvent2 , e.g. BeforeNavigate2,DownloadBegin,DownComplate etc, but how to i specify it so it only works to a image file ?
any help is much appreciated, thx a lot
|
|
|
|
|
Hi All,
I am fairly new to C++ (but don't hold that against me) and I am trying to manually load a 32-bit bitmap into memory from a file. By manually I mean reading each structure (BITMAPFILEHEADER, BITMAPINFOHEADER, etc.) and bitmap bits using ReadFile. I am pretty confused about how the bitmap bits are stored... are they stored BGR or RGB? and where is the alpha bit stored? If after reading the bits into memory and have an UCHAR* to the bits, how do I extract the blue, green, red and alpha color intensities?
Thanks.
Robert
|
|
|
|
|
I have a simple MFC custom control which extends CWnd.
It has a CButton member, nothing more.
I want to create the Custom control at run time in my main dialog (i.e. Without using Resource editor)
And I want to use the following code in the OnInitDialog() to create the Custom control at run time:
m_MyCustomControl.Create(...);
It sounds simple, but I was failed to do it. Can somebody try out it or gives me some help?
|
|
|
|
|
Hey! I've been floating around in here for a while now, doing my thing, helping out where I can. Now I got another request from you all. I need/want to assign an icon to my CMD-LINE programs. I know it can be done, the guys over at FoundStone do it all the time. Requesting suggestions and/or code from you all.
Cheers!
|
|
|
|
|
Simply add an icon resource to your .exe. Visual Studio does not automatically create resources and icons for console apps, as it does with dialog based ones, which is why the have no icon by default.
Windows uses the first icon in the resources as the app icon by default.
Cheers,
Nick
|
|
|
|
|
Background: I have a standard win32 application. The application doesn't have a user interface and behaves somewhat like a service. However I can't run it as a service because I sometimes need to use the desktop.
I need to make sure that my program exists gracefully on any error. I need to illiminate absolutely all error message boxes like "Runtime error" "Abnormal termination" message boxes. How can this be done??
|
|
|
|
|
To begin use
try
{
}
catch(...)
{
}
or catch every error you might know
<italic>Work hard and a bit of luck is the key to success. You don`t need to be genius, to be rich.
|
|
|
|
|
I've used the catch(...) but that doesn't garantee that "Runtime Error! .... This application has requested the Runtime to terminate it in an unusual way." message box doesn't show up.
|
|
|
|
|
>>However I can't run it as a service because I sometimes need to use the desktop.
You can make a service to display user interfaces and receive user inputs by setting SERVICE_INTERACTIVE_PROCESS attribute of a service.
There is no spoon.
suhredayan
|
|
|
|