|
What is 'a member variable for the function'? If it's a member variable of your dialog class, then yes, that is what you should do. You can also make a static variable:
<br />
class FooDialog : public CDialog<br />
{<br />
void OnButton1()<br />
{ <br />
static int counter = 0;<br />
counter++;<br />
}<br />
}<br />
<br />
|
|
|
|
|
Thanks for the help with the static. My counter works now, but can you show how to make OnButton a return function or someother way for other functions to use the counter variable? Thanks
|
|
|
|
|
Hello,
Add a memeber variable in your class:
int m_nCounter;
In the constructor add:
m_nCounter = 0;
In the OnButton1() add:
m_nCounter++;
remove:
static int counter = 0;
counter++;
this should do the trick...
A student knows little about a lot.
A professor knows a lot about little.
I know everything about nothing.
|
|
|
|
|
When I read this question the first time I was screaming inside... What you want has nothing to do with a dialog and has everything to do with knowing basic C++. These are basic properties of classes in general. I would suggest looking at a C++ tutorial before trying to make a complicated MFC program.
Here is one that should help:
http://www.codeproject.com/useritems/beginnerclass.asp[^]
John
|
|
|
|
|
yah ur right but i think a lot of people see mfc as c++ so to speak so they think learning mfc is learning c++
if u get my meaning here
"there is no spoon" biz stuff about me
|
|
|
|
|
I agree... When I posted that I thought it sounded a little rude (I try hard to avoid that), but to me it was obvious that they did not know very much C++. Better learn C++ before you try MFC...
John
|
|
|
|
|
Hi All,
How do I get the information that a user enters from a edit box?
I want to open a file that the user enters...so basically i want to get the string entered by the user into the open file call.
Many thanks in advance.
|
|
|
|
|
void GetWindowText( CString& rString ) const;
or if you assigned a CString variable to the Edit box, use UpdateData(TRUE) and the variable should contain the text.
Maximilien Lincourt
"Never underestimate the bandwidth of a station wagon filled with backup tapes." ("Computer Networks" by Andrew S Tannenbaum )
|
|
|
|
|
CString strFilename;<br />
m_edit.GetWindowText (strFilename);
/ravi
Let's put "civil" back in "civilization"
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Use GetWindowText() in MFC or handle the WM_GETTEXT message in win32
If you can keep you head when all about you
Are losing theirs and blaming it on you;
If you can dream - and not make dreams your master;
If you can think - and not make thoughts you aim;
Yours is the Earth and everything that's in it.
Rudyard Kipling
|
|
|
|
|
Thanks everyone....I was using GetLine, didn't realize until right now that was only for multiple line boxes.
can you tell i am new to programming?!?!?!
In another case, I will have a number. Is there a way to determine if this number is a negative? How do I just look at the first character in the string?
|
|
|
|
|
Use atoi() for an int or atof() for a float and check if the number is less than zero.
<br />
CString str = "-9";<br />
int value = atoi(str);<br />
if (value < 0)<br />
{<br />
.....<br />
.....<br />
}
|
|
|
|
|
Thanks....
Is there a place where I can find all these types of conversion "tool/methods"? I know what this one does (atoi) but I know there are other ones that I may find useful.
Many thanks again.
|
|
|
|
|
Look on your MSDN Library CD
|
|
|
|
|
Jay Hova wrote:
can you tell i am new to programming?!?!?!
Not unless you tell us! Even experienced folks forget stuff now and then.
|
|
|
|
|
I want get a associated icon from a file system (for example c:\test.doc") using SHGetFileInfo function and save it in a file (for ex "C:\myicon.ico").
But GlobalSize and GlobalLock returns 0 (invalid value!!!).
I've read an IconPro example (in vs6example.exe) but I didn't found a good solution!
Please give me a good idea!
Tnk you
/******MY CODE*****/
CString nomefile = "c:\\test.doc";
HICON hGen32Icon;
HIMAGELIST hSysImageList;
SHFILEINFO shfi;
int fh;
UINT uiSize;
DWORD dwSize;
LPVOID lpGMem;
OFSTRUCT of;
hSysImageList = (HIMAGELIST)SHGetFileInfo
(nomefile,
0,
&shfi,
sizeof (SHFILEINFO),
SHGFI_SYSICONINDEX | SHGFI_SMALLICON);
hGen32Icon = ImageList_GetIcon (hSysImageList,
shfi.iIcon,
ILD_NORMAL);
dwSize = GlobalSize(hGen32Icon); /*Don't work*/
lpGMem = GlobalLock(hGen32Icon); /*Don't work*/
fh = OpenFile ("c:\\myicon.ico", &of, OF_WRITE | OF_CREATE);
if (fh == -1) // If NOT opened successfully.
{
MessageBox("Unable to create file", NULL, MB_OK );
}
uiSize = _lwrite(fh, (LPSTR)lpGMem, (UINT)dwSize);
_lclose(fh);
|
|
|
|
|
Hi Dears
Kindly Tell me How to run a script (.vbs) in VC++, Please help ....
I'll very be thankful
Atif
Watch Your Thoughts for they will become your actions.
Watch Your Actions for they will become your habits.
Watch Your Habits for they will become your beliefs.
Watch Your Beliefs for they will determine your destiny.
|
|
|
|
|
|
hello
i want to use edit boxes in userdrawn list box control. can anybody help me in this matter. i would also like to know how to comunicate with it after creating userdrawn editlist boxes
thanking you
chan
|
|
|
|
|
I want to draw a picture , in which one color must not be drawn,
-transparent color,
but at usual samples I must redraw picture fully transparent - get background,
repaint at transparent places,
and than only paint picture.
Here I must REALLY redraw more one time full place- that is visible like flickering.
Is it possible to redraw trabsparent bitmap with no repaint?
Or is there e else method without flickering?
(BeginDraw()
EndDraw() -do this? )
Does standart dc.TransparentBlt() draw with no flickering?
thanks you
|
|
|
|
|
You could draw the background onto a memory dc, draw your transparant picture to there, then bitblt to the screen, and handle WM_ERASEBKGND there ofcourse to prevent the flickering.
|
|
|
|
|
But how can I get background - if not repainting my picture
invisible first?
That is problem!
|
|
|
|
|
he means draw ur background image into a memdc THEN draw ur transparent image over it into the same memdc (avaoiding drawing the color u dont want to see) then bitblt it to the screen
if u dont have a background image u want to see underneath the transparent image why bother with transparency?
hope that helps
"there is no spoon" biz stuff about me
|
|
|
|
|
fisrtly how do i make arrows, lines, circles or squares objects that i can
cut and paste and copy, then with that it would help me being able to save the diagram in xml, but not in diagram format but in code. this will help me
edit the loaded version of the diagram, ie cutting and pasting lines and squares that were loaded from a saved diagram....an argoUML use case project
smile...its your destiny
|
|
|
|
|
Please clarify. Do you want to write a program that lets a user draw lines and arrows that can be edited and be saved to XML?
|
|
|
|