|
Call UpdateData(true) before you read value from the control and update the member variable. Call UpdateData(false) before you update the control on the screen to reflect the value of the member variable.
UpdateData(true);
m_edit2 = m_edit1;
UpdateData(false);
Remember that UpdateData() will update the state of every other control and member in your dialog as well.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
modified on Tuesday, February 12, 2008 4:49 AM
|
|
|
|
|
In the button event handler, call
(1) UpdateData(TRUE);
to assign to the variable iVar the (numeric value corrensponding to) edit box text.
Then set:
(2) iCalcValue = iVar;
and, finally, call
(3) UpdateData(FALSE);
to set the edit box text according to iCalcValue .
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Thanks guys, I really appreciate it.
I'll come back with something more difficult next time
|
|
|
|
|
Hi guys can any one tell me whether there is an inbuild function that converts hexa value to decimal.
I have used sscanf(charVar,"%X",intVar) when I do this the output is same as that of input (i.e., same hexa value). can any one help?
Regards,
lgatcodeproject
|
|
|
|
|
lgatcodeproject wrote: converts hexa value to decimal.
That doesn't really make sense to me. A value is a value, it's only a representation of that value that can be decimal or hexadecimal. In your sample, you have a string that contains a hexadecimal representation of a number and you store that value in the intVar. But at this time, it is a value, and not a representation anymore. There is no output possible of your intVar (if you look at it from your debugger, the debugger will show you a representation of the number, which you can change without affecting the value).
I would have guessed that you want to convert a string that contains a hexa representation to a string that contains a decimal representation but your code snippet contradicts that.
So, what are you trying to do exactly ?
|
|
|
|
|
Hello,
Consider this situation, I need to iterate 'iLength' number of values for a business logic. 'iLength' is a value represented in hexa. In a while loop, to perform a boundary check I am using this 'iLength' value.
while(++iPosition<= iLength)
My assumption is that this boudary check requires the value to be an integer is not so? If not clarify?
Assuming my assumption is true how do I represent a hexa value in decimal?
eg. if 'iLength' = 2b, I need 'iLength' to contain 43? How ?
Kindly clarify. Thanks for your quick response.
Regards,
lgatcodeproject
|
|
|
|
|
lgatcodeproject wrote: eg. if 'iLength' = 2b, I need 'iLength' to contain 43? How ?
You have to do nothing, supposing iLength is declared as an integer variable.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
If iLength is an integer (which I suppose), it IS a number. iLenght contains your value and it has nothing to do with "2b" or "43" because these are only representations of your number. You have to make the difference between the value itself (which not hexa, decimal or whatever, it is just a value) and how you want to represent it (which is only used if you want to print the value in a string).
Do you understand the difference ?
lgatcodeproject wrote: 'iLength' is a value represented in hexa
That doesn't make sense: iLenght is an integer and that's it. An integer is never represented. If you look at it from your debugger, that's because your debugger is configured to display a representation of it in hexa, but you can change the representation to decimal without affecting the value at all.
|
|
|
|
|
Hi,
I understand the difference between a value and its representation. I need clarification on this, "a value means the same in what ever way it is represented am I right? then what is the real need to represent an value in different ways?"
Regards,
lgatcodeproject
|
|
|
|
|
Because a representation maybe convenient in a particular context. For instance, hexadecimal one uses exactly two digits to represent all of the values of byte (to display byte values with decimal representation you may need three digits, but a large part of decimal three-digits-numbers cannot fit in a byte ); binary representation maybe opportune whenever you need to display a bit mask, and so on..
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
If intVar is an int, then it's not decimal, binary, hexadecimal.
You can display intVar in your debugger in hex if you show
intVar,x
or decimal using
intVar
Try right clicking on the watch window and de-select the "show hex" option. Beyond that, I don't understand your problem.
Iain.
Iain Clarke appearing in spite of being begged not to by CPallini.
|
|
|
|
|
you have to pass the address of the int variable to sscanf , for instance:
int i;
sscanf("1F","%X", &i);
sets i=31; .
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Dear all
I have one visual C++ 6.00 MFC dll project.
It contains both C and C++ files.
Every time I open the project and make it clean and ther rebuild all it,
following errors occures.
Linking...
mfcs42d.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in MSVCRTD.lib(dllmain.obj)
mfcs42d.lib(dllmodul.obj) : warning LNK4006: _DllMain@12 already defined in MSVCRTD.lib(dllmain.obj); second definition ignored
Creating library Debug/ecpdll.lib and object Debug/ecpdll.exp
Debug/ecpdll.dll : fatal error LNK1169: one or more multiply defined symbols found
Error executing link.exe.
Creating browse info file...
ecpdll.dll - 2 error(s), 1 warning(s)
When I delete the C file and the header file of it and then re add them to the project this error removes but this style is not good.
May u please help me.
Regards
Tappe
|
|
|
|
|
Solution ->[^]
Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
|
|
|
|
|
hi try this
in project settings, select using MFC dlls in one of the combo boxes.
|
|
|
|
|
Hi all,
I would like to know whether it is possible to create a vector with more than one level range. For example, lets say you have two sets of integers and you want to populate a vector , how would one do it?
The code piece below shows four ints with value 100, but what if one wanted two sets of four ints with a value of 100.
vector<int> second (4,100);
Level 0 Level 1
0 0
1 1
2 2
3 4
...
Many thanks in advance
Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
what about vector of vector ?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You/codeProject$$>
|
|
|
|
|
Thank you for the reply ... May I ask for a very short example else thanks for the help.
Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
Would this be an example of such occurance, if so does the following structure perform the same function, if not how can I change the vector to perform the same function:
struct C
{
string coid;
string actualCoid;
}COID[100];
#include <iostream>
#include <vector>
using namespace std;
main()
{
vector< vector<int> > vI2Matrix(3, vector<int>(2,0));
vI2Matrix[0][0] = 0;
vI2Matrix[0][1] = 1;
vI2Matrix[1][0] = 10;
vI2Matrix[1][1] = 11;
vI2Matrix[2][0] = 20;
vI2Matrix[2][1] = 21;
cout << "Loop by index:" << endl;
int ii, jj;
for(ii=0; ii < 3; ii++)
{
for(jj=0; jj < 2; jj++)
{
cout << vI2Matrix[ii][jj] << endl;
}
}
}
Thanks in advance
Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
If i draw some image, lines, rectangles etc. in OnPain() of dialog box then it takes some time. Suppose i draw image,rectangle on mouse click and release event. I can call repaint from mouse click/release function and it's working fine. But suppose if i want to draw some lines on mouse move function then i need to call repaint from mouse move function and it gives flickering problem. To solve this i plan to draw image, rectangle etc in a memory device context on mouse click/release functions. and for mouse move first i'll draw data from memory device context and then i'll draw line on top of it. But it's not working. Can someone give any example to solve that problem.
Manoj Kumar Chauhan
|
|
|
|
|
Which device context you are using on window mouse message handler and are you using ::ReleaseCapture funtion after releasing mouse.If possible pls give me code to understand your problem.
Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
|
|
|
|
|
The code is simple. Just Create a dialog base application. Add a static control on dialog box. Make a class for this static control(derived from CStatic). Now draw in this class. In Onpaint() of this class draw some image,rectangle, lines etc. Add all mouse functions in this class. Call Invalidate() from mouse click/release functions. Upto now there is no problem. Now call Invalidate() from mouse move function. You'll see flickering. To solve it take an offscreen buffer. Create image/rectangle in offscreen buffer and draw it on view when Invalidate() is call from mouse click/release function. Otherwise form mouse move function, dont create offscreen buffer, just use previously created offscreen buffer and draw it on view. Then draw lines. I'm not using any capture function like ReleaseCapture(). When i dtied this then i can see only lines. I cant see any image/rectangle. What i want
I want a 2 layers. bottom layer should contains image and rectangle and top layer contains only lines.
Manoj Kumar Chauhan
|
|
|
|
|
are you using CClientDC device context or CPaintDC on OnMouseMove function ? And when i see your code it is clear for me where is the problem?
Yes U Can ...If U Can ,Dream it , U can do it ...ICAN
|
|
|
|
|
I'm not using any device context in mousemove. From mouse move i'm calling Invalidate. And in Ontain, i'm using CDC to create memory device context. If your code is working fine then please send here if you can.Or please mail to my id gkv_manoj@yahoo.com
Manoj Kumar Chauhan
|
|
|
|
|
1/ Are you sure you're just invalidating the CMyStatic control? If you're also invalidating the dialog box, then you'll get flickering.
2/ If your code is working, but not with the memory context, then have a look at Keith Rule's CMemDC article. I've used his CMemDC in many places, and it's great.
Just do a search for his name. He didn't write many articles, but it's a golden one.
Iain.
Iain Clarke appearing in spite of being begged not to by CPallini.
|
|
|
|