|
how i can change the parent dialog's variables from a child dialog?
erfan
|
|
|
|
|
pass the this pointer of the parent class to the child.
cheers..Milton Kb
|
|
|
|
|
|
Are you sure you want to do this? It's considered bad OO design for a child object to operate on items belonging to its parent. Consider sending the parent a message instead.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
thanks.
i know this is a bad way but i need it
|
|
|
|
|
I have ever seen only the function like this
SomeFuntion(input1,input2);
such as
FindWindow(NULL,m_input);
but I never seen the funtion like this
(Something)SomeProcedure;
such as
(HOOKPROC)KeyboardProc;
What does it mean ?
|
|
|
|
|
(SomeType) is an explicit cast into the SomeType type.
such code line actually changes the type of the expression into the type specified.
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|
|
It seems that you see a cast operation. For instance (int)7.2 means that the float-point value is converted to an integer, obtaining 7 . Casting can be applied for function pointers too. Thus, (HOOKPROC)KeyboardProc means that the address of KeyboardProc function is interpreted as a callback function required by the second argument of the SetWindowsHookEx call.
|
|
|
|
|
Max++ wrote: but I never seen the funtion like this
(Something)SomeProcedure;
such as
(HOOKPROC)KeyboardProc;
When you see that you are generally looking at a cast. However, in older code, especially from the U*ix world or from older U*nix developers, you may see something like:
<code>(void)</code>printf( "Some String" );
<code>(void)</code>strcpy( caSomeBuffer, "Some Other String" );
<code>(void)</code>sprintf( caSomeBuffer, "%d-%d-%d", iVal1, iVal2, iVal3 ); In this case, I believe you are seeing a construct that means something along the lines of "I am intentionally ignoring the return value of this function." I believe that some compilers may even complain (or may have complained) about disregarding return results like this(?).
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
|
I've created a Button and what i'm trying to do is when I click the button I want a message box to pop up...
void ksclass::OnBnClickedButton1()
{
::AfxMessageBox(_T("Hello Wolrd !"));
// TODO: Add your control notification handler code here
}
the ::AfxMessageBox(_T("Hello Wolrd !")); helped with the errors but when I run then click the button... nothing happens...
Thanks
Kitty5
|
|
|
|
|
Since i am trying to put text (CDC) on a Cstatic (which looks bluish on my screen) I would like to set the background color of CDC for the TextOut to be the same as the label color. I tried doing the following in the label class but of course its incorrect. HOw do I get the color of the label so I can SetBkColor of the CDC?
COLORREF cl = GetBkColor(GetDC());
GetBkColor' : cannot convert parameter 1 from 'class CDC *' to 'struct HDC__ *'
thanks,
sb
|
|
|
|
|
If this does not help:
COLORREF cl = GetDC()->GetBkColor();
nor
COLORREF cl = m_cMyLabel.GetDC()->GetBkColor();
then you can try this:
COLORREF cl = (COLORREF)GetSysColor(COLOR_3DFACE);
|
|
|
|
|
|
Michael Dunn wrote: Those calls to GetDC() are bad - you need to release every DC you get.
You are right -- explicit releasing should be preferable.
Actually MFC is able to release various handles at idle time. Values returned by GetDC and other functions are temporary objects which are stored in a collection. They a released between message processing.
|
|
|
|
|
Greetings:
I have this application that I'm writing under VS 2003 using C++ and MFC. This one dialog box contains a fixed segment, located in the left-hand part of the dialog, where all of the controls inside will not change. One of the controls is a list box and as the user selects a single item from the list box, the controls on the right automatically change to correspond with the selection. One selection may cause the controls on the right to become a couple of input boxes. Another selection may cause the controls on the right to become a combobox and some check-boxes. Get the picture?
The problem is that I am unsure about how to do this. I thought at first that just using property pages would be the way to go but I am rather sicked by the fact that the property sheet that "holds" the property pages is so inflexable. It is very difficult to resize the property sheet and then place the page part of the sheet into the area that you want. Furthermore, I noticed that the controls that are positioned in the sheet must be placed there programmatically. I hate that idea.
I would prefer to NOT have to paint and repaint my controls programmatically. I would like to draw each of the control sets in the resource editor and then come up with some easy way to just swap them in and out.
Has anybody out there done something like this? Any advice?
Thanks in advance,
Mark
|
|
|
|
|
Jethro63 wrote: This one dialog box contains a fixed segment, located in the left-hand part of the dialog, where all of the controls inside will not change. One of the controls is a list box and as the user selects a single item from the list box, the controls on the right automatically change to correspond with the selection. One selection may cause the controls on the right to become a couple of input boxes. Another selection may cause the controls on the right to become a combobox and some check-boxes. Get the picture?
The application that I am currently working on does the exact same thing.
Jethro63 wrote:
I would prefer to NOT have to paint and repaint my controls programmatically. I would like to draw each of the control sets in the resource editor and then come up with some easy way to just swap them in and out.
Has anybody out there done something like this? Any advice?
Just add all of the controls to the dialog template, end then use EnableWndow() accordingly.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
One of the ways is to dump all possible controls onto the dialog template (as suggested). To make this easier, create several arrays that contain the control IDs for each specific collection/selection, and then loop through them to show/hide/enable/disable as required. (Tip: use CWnd::SetRedraw( FALSE ) to disable drawing while you do this and CWnd::SetRedraw( TRUE ) followed by CWnd::RedrawWindow() to enable it after to prevent flickering.)
Another thing to do which is easier especially if you have lots of controls and you have to make sure they all have the correct tab order is to create several dialog templates, one for each collection/selection, and dynamically show/hide them as "floating" modeless dialogs.
This also makes it easier to place a collection/selection's specific functionality into its own file (one per dialog template).
You have to be careful of placement so things like moving the parent automatically moves the floating dialogs, and have to do a little work to make sure users can tab into and out of the active floating dialog correctly, but it might be easier and/or cleaner depending on your situation.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
|
Thanks for the help on this everybody. I guess I'm a bit perplexed at the prospect of designing a dialog by positioning ALL of the possible controls on the dialog and then turning them ON and OFF in context with the users selection. In my application, there are, I think, 6 different formats. Some are simple and some not so simple. In the resource editor, this is going to look like a dog's breakfast! If there are too many different formats you wish to support, this approach would surely become unfeasible.
I am surprised that VS does not offer an easier way of doing this...
Thanks again!
Mark
|
|
|
|
|
Is there an easy way for a server, implemented with CSockets, to know when one or more clients have disconnected antisocially e.g. network unplugged, powered off etc? I want to prevent a build up of 'obsolete' CSockets in my servers client list.
TIA
|
|
|
|
|
Use CAsyncSocket instead of CSocket and handler OnClose() event.
|
|
|
|
|
Great thanks!
Can't I can still use CSocket as this is subclassed from CAsyncSocket?
Thanks again!
Tony
|
|
|
|
|
He's right, but it doesn't work in all cases:
client --- router ---- router -- server
^ break connection here
If the network connection is broken between the client and server here, neither receives an error until they try to send data. Depending on how things are setup in your app, you might want to consider doing a ping message.
|
|
|
|
|
Hi all,
i want to execute a programm (f.e. ipconfig.exe) with CreateProcess and redirect the output to a char* if possible. The question is: How could this be done? As i am new to CPP, i haven't got a clue...
Can anybody give me a hint please?
Thanks in advance!
-- modified at 10:08 Wednesday 14th June, 2006
|
|
|
|