|
If I understand you correctly, you would like the value contained in the EDIT_1 to be shown in the EDIT_2 control, on pressing BUTTON_1 ?
try the following...
void CMFC_7Dlg::OnButton1(){
// Force DDX- DDV to do it´s stuff
// Save and Validate (TRUE) parameter
// **********************************
UpdateData(TRUE);
// Set the values as required
// **************************
m_var2 = m_var1;
// Force DDX - DDV to do it´s stuff
// Read values from member variables,
// and display them (FALSE) parameter
// **********************************
UpdateData(FALSE);
}
alternativly you could do the following
void CMFC_7Dlg::OnButton1(){
// Force DDX- DDV to do it´s stuff
// Save and Validate (TRUE) parameter
// **********************************
UpdateData(TRUE);
// Set the values as required
// **************************
m_var2 = m_var1;
// Update the UI to show the change
// ********************************
SetDlgItemInt(IDC_EDIT_2, m_var2, FALSE);
}
regards
Phil
bum... and I thought I´d got rid of all the bugs
|
|
|
|
|
If I understand you correctly you need to eneter Edit1 value to Edit2 value
void CAnswerView::OnBnClickedButton2()
{
CString str;
m_Edit.GetWindowText(str);
m_Edit2.SetWindowText(str);
//int Index=atoi(str);
}
I tesed this code and work Now this code is good or bad?
|
|
|
|
|
WhiteSky wrote: I tesed this code and work Now this code is good or bad?
It is the only way that will not end in blood, sweat and tears, IMHO.
NEVER EVER call UpdateData() yourself, but use control-variables and Get/SetWindowText.
The value-variables are for shielding the inner workings of a dialog from the outside.
INSIDE a dialog they only spread confusion.
So far my personal, very dogmatic views.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
-- modified at 9:42 Tuesday 14th March, 2006
UpdateWindow -> UpdateData
|
|
|
|
|
jhwurmbach wrote: NEVER EVER call UpdateWindow()...
Perhaps you meant UpdateData() .
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
Yet another example of why UpdateData() should be avoided. It's just too easy to mess up. You'd be better off using GetWindowText() instead.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
I do not think that UpdateData(x) should be avoided. If used correctly, it is a lot eaiser then GetWindowText/SetWindowText. From the code snippet provided, It is not really clear what the purpose of two variables si, for one value to be retrieved...
just my tuppence..
Phil
bum... and I thought I´d got rid of all the bugs
|
|
|
|
|
Phil.Benson wrote: If used correctly...
That's a mighty big if there. The problem is that most beginners do not use it correctly and end up butchering their code just to get around its caveats. I find it best to avoid altogether. GetWindowText() and SetWindowText are a lot cleaner and you can tell exactly what is going to happen. Using UpdateData() is an all-or-nothing operation.
Consider the situation where you set some member variables, call a dialog's DoModal() method, call UpdateData() , then click the Cancel button. Now the member variables are potentially not in the same state they were prior to calling DoModal() . You should be able to assume that member variables retain their same value before and after if the Cancel button has been clicked. Use of UpdateData() makes this a bad assumption.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
David wrote
"That's a mighty big if there. The problem is that most beginners do not use it correctly..."
Nobody said programming is easy. If it was, we would not get paid as much
As for choosing Cancel, do you manipulate application data directly within the dialog? Or do you wait for the result (IDOK or IDCANCEL) before making any changes resulting from the data being changed within the dialog?
again, just my tuppence
Phil
bum... and I thought I´d got rid of all the bugs
-- modified at 9:43 Tuesday 14th March, 2006
Here on code project, If I can remember correctly it was PJ Ahrens, has written an interesting article about DDX-DDV in the MFC
|
|
|
|
|
I need to integrate Activex control(OCX) object into ATL COM Server DLL project. I created a dialog in my the project and added activex control. After adding the ActiveX control my other parts of the program are not working properly. The COM DLL calls CoCreateInstance() to connect to another component. At this point it hangs. If I remove the ActiveX object from the project everything works fine. Do you guys have any idea?
kars82
|
|
|
|
|
Hi again
i have another simple question
i'm doing the following
string text;
int lenght=text.lenght;
compilation error::
error C2440: 'initializing' : cannot convert from 'unsigned int (__thiscall std::basic_string<char,struct std::char_traits<char="">,class std::allocator<char> >::*' to 'int'
Conversion is a valid standard conversion, which can be performed implicitly or by use of static_cast, C-style cast or function-style cast
Error executing cl.exe.
What is the problem i've seen this in many codes what is wrong with mine
Thanks in advance
|
|
|
|
|
antonaras_marcou wrote: string text;
int lenght=text.lenght;
string text;
int nLength = text.length();
Nibu thomas
Software Developer
|
|
|
|
|
Thanks Nibu thomas
appriciate the help
it's working fine now
|
|
|
|
|
They didn't do the beginners any good with this stupid property-notation in the Hype-languages.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
To Whom it may concer:
I have a serious issue with the development under MS Exchange Database using unmanaged C++. I would really appreciate ( for a bootle of BEAR if you live in Kyiv, Ukraine) if someone can provide me with the documentation and/or samples of such code.
Thank you in advance!
For more info please advice
|
|
|
|
|
hi!! is any1 familiar wiz openGl? I want to integrate terrain codes which r in openGL in MFC n am having sm problem.. cud any1 plz help me
|
|
|
|
|
You could go to the website nehe.gamedev.net/ you will find some good tutorials on opengl at this site.
|
|
|
|
|
adiilah wrote: I want to integrate terrain codes which r in openGL
as mentioned go to Nehe.... if the issue is how to do terrains in OpenGL, go here: http://www.vterrain.org/LOD/Implementations/index.html[^]
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
What do you exactly mean by "terrain codes in OpenGL" ?
SkyWalker
-- modified at 14:48 Tuesday 14th March, 2006
|
|
|
|
|
Hello People,
I want to paint the caption bar dynamically with color of my choice. The Font and Color of the Caption Bar text should change.
Besides, I also want to change the border color to match the Caption Bar Color.
Has Anyone done this earlier?
Any help on this?
Sukant Tiwary
|
|
|
|
|
maybe it is some helpful to you
http://www.codeproject.com/dialog/skinedcaptionbars.asp
|
|
|
|
|
After repeated database operations while opening closing a child window of a dialog applications, a message box will pop up saying "Too many client tasks. Driver's SQLSetConnectAttr failed". I am a beginner in mfc/C++ programming and need this program runnning ASAP and any help would be appreciated. thanx
|
|
|
|
|
For every connection that you create, there must be a matching destroy. Why not just create one connection when the application is started, and destroy it when the application closes? Creating a connection to a datasource can be a very costly operation.
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
The code given below works fine as long the mouse is on the application dialog,
but as it leaves the dialog mouse position coordinates do not change.
I have set hook as under;
pfnMyMouseMonitor = (HOOKPROC)MouseProc;
hMouseHook = ::SetWindowsHookEx(WH_MOUSE,pfnMyMouseMonitor,(HINSTANCE) NULL, GetCurrentThreadId());
Mouse function is as under
LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam)
{
MOUSEHOOKSTRUCT* pms = (MOUSEHOOKSTRUCT*)lParam;
//pms->
if (nCode == HC_ACTION)
{
str.Format("x = %d : y = %d",pms->pt.x ,pms->pt.y);
px->SetWindowText(str); // px is pointer to static control on dialog
}
return(::CallNextHookEx(hMouseHook, nCode, wParam, lParam));
}
I donot want to use dlls.
Thanks in advance.
|
|
|
|
|
u can't put a globel mouse hook unless u put the hook function in a dll.
In this case in order to get the window text below, use
SetCapture()
nave
|
|
|
|
|
The system function call waveInGetPosition retrieves the current input position of the given waveform-audio input device. The function call returns the position in the parameter MMTIME in the given format. (if possible)
In my application I use the TIME_SAMPLES format wich specifies the current position in an offset in samples since the last time the waveform-audio input device was reset.
My question is: What would happen if a recording gets to long (nSamples>(2^32)-1).
I think it just simply wraps around the current position but I am not sure about this. (I have never tried) And it would take me about 12 hours to figure out by myself. (4294967296/96000/3600=12.43)
Thanks.
|
|
|
|