|
use CStrings if u can
CString urString;
in the loop:
urString = a [i];
CString t( '0', numberOfSpaceNeeded );
t += urString;
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Amazing! Thanks! I didnt know CString had such a handy constructor.....
Appreciate your help,
ns
|
|
|
|
|
You could format the number with the approprite lenghth
CString aString;
aString.Format( "%7i", 123 );
|
|
|
|
|
Maximilien wrote:
CString aString;<br />
aString.Format( "%7i", 123 );
You forgot the zero:
aString.Format("%07i", 123);
|
|
|
|
|
|
I write a class which kicks off a thread in constructor and terminated it in destroyer. This thread has a message queue, and in the switch-case, calls the class' member functions or member variables. And so far, I got the following reward :
illegal call of non-static member function
In my point of view, It's reasonable to use massage queue to manage member functions and member variables. it sounds good but I kick a stone, tell me why and how to make a difference.
Thanks
Extreme programming. Do the No.1
|
|
|
|
|
a thread function (the one that you use to start the thread) cannot be a member function of a class, unless that function is static.
-c
Support regime change. Vote.
|
|
|
|
|
why??? why must be static? u mean serval instances have only one thread function? then once again, how to call a member funtion in a thread function?
What's happening in backyard?
thanks
Extreme programming. Do the No.1
|
|
|
|
|
stevenson wrote:
why??? why must be static?
the thread proc can't be a non-static member function because there is no way to provide the "this" pointer to provide an object context for that member function to be called from. it's like this:
int i = CString::GetLength();
GetLength makes no sense without an actual CString object. a static member function doesn't require an actual object instance, so you can use it as a thread proc.
you can pass an object into the thread proc and use it indirectly:
volatile dataStruct data;
data.pMyObject = &TheObjectIWantToUse;
AfxBeginThread(ThreadProc, (void *)&data, THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED);
...
UINT ThreadProc(void *p)
{
dataStruct *pData = (dataStruct *)p;
now you can use pData->pMyObject;
}
-c
Support regime change. Vote.
|
|
|
|
|
Hi,
I have launch the hh.exe ( help viewer) via CreateProcess(). I am trying to close this window when my main program exits. How do I do that?
Here's a snip of my code...
bSuccess = CreateProcess ("C:\\WINDOWS\\HH.EXE"," NATURAL.CHM",
NULL, NULL, TRUE, NORMAL_PRIORITY_CLASS,
NULL, NULL, &si, &ppi );
helphnd = ppi.hProcess;
CloseHandle ( ppi.hThread );
CloseHandle ( ppi.hProcess );
The code is written as part of defining a 'Help' menuitem. Quite new to the idea of process, copy this idea from FAQ in this website. If CloseHandle is executed right after CreateProcess, that means the process should have finish and return to the executing program, therefore closehandle would do the cleaning up? Now, I am executing something in the ::OnCloseDocument(), how do I check whether the help program is still running,so that I wouldn't be trying to close the program?
|
|
|
|
|
unsigned long status;
int rv = GetExitCodeProcess(ppi.hProcess, &status);
Todd Smith
|
|
|
|
|
THanks for the reply. It's this function just checking whether the process is closed? How to close the process then?
|
|
|
|
|
|
Looks like we can only insert strings, so if i want to put in ints or floats, so I have to first atoi, atof them before inserting them? ?
Appreciate your help,
ns
|
|
|
|
|
Correct, but you need itoa or ltoa (ints to strs), not atoi (strs to ints)...
Not sure if there's a ftoa, so you may need to do an sprintf() or something similar...
Chris
"If at any time I announce that a nation or kingdom is to be uprooted, torn down and destroyed, and if that nation I warned repents of its evil, then I will relent and not inflict on it the disaster I had planned. And if at another time I announce that a nation or kingdom is to be built up and planted, and if it does evil in my sight and does not obey me, then I will reconsider the good I had intended to do for it." -- Jeremiah 18:7-10 (God, commenting on the value of the United Nations)
|
|
|
|
|
Hi,
It's possible to find a window by a incomplete name ??
Ex.: Finding a window that has the name "App Test", ::FindWindow ("App Tes?")
Other thing: How find a window by a class name ??
[]'s
Cris.
|
|
|
|
|
Cris wrote:
How find a window by a class name ?
According to MSDN, you should call FindWindow with lpszWindowName set to NULL.
rechi
|
|
|
|
|
But how I get the class name ??
I am using a dialg based app, how I registry the class name ??
|
|
|
|
|
Cris wrote:
how I registry the class name ?
This should be too complicated. Study RegisterClassEx for it.
Cris wrote:
But how I get the class name ??
Use Spy++.
rechi
|
|
|
|
|
You can use ::GetWindow() that will returns the HWND of the window, then you can use ::GetWindowText
Regards
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
Can u enumerate all the windows (and child windows if needed) and get the text in the window, and check if u can find ur text in it??
see EnumWindows and strstr or CString::Find
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
But I don't have the complete name. I know that the name begin with "App Name Te...". Can I make anything like this ???
[]'s
|
|
|
|
|
EnumWindows(EnumProc, 0);
and the enum proc:
BOOL CALLBACK EnumProc(HWND hWnd, LPARAM lParam)
{
char szWindowText[256];
memset (szWindowText,0,256);
GetWindowText (hWnd,szWindowText, 255)
if(strstr(szWindowText,"The part u want to find"))
{
// hWnd is ur window
}
return TRUE;
}
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
You need to use the function that enumerate the window like your string...
The Funtion GetWindowText extract the complete name...
If you are asking if exists a function that enum window with title like a specific string, I need to say, I'm Sorry....
The only method is to enum all the window looking for the window that you want...
Regards...
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
According to MSDN I am understanding that isDigit will recognise a number, but what if I want to find out that say char* abc = "1234.5678" is a number or not? THen if I'm stepping along the string checking each character, if I hit the decimal point, its not going to like that and it wil say its not a digit> so what can I use to figure out if my text is a double or float?
Appreciate your help,
ns
|
|
|
|