|
I think you probably want to be using sprintf(). See MSDN.
Signature space for rent. Apply by email to....
|
|
|
|
|
std::ostringstream could help you.
You can stream almost anything into it using operator<< and get the text using the ostringstream s str() function.
|
|
|
|
|
I have tried to test an application i have found into microsoft support, it's Q186120: "Use MFC to automate excel and fill a range with an array"
I have a problem when i try to run it at the following line:
saRet.PutElement(index, &d);
or
saRet.PutElement(index, v.bstrVal);
(it depends on checkbox is false or true)
when i try to debug it tell me that there's a problem in the function AfxCallWndProc.
So, i would like if someone have tested this application and if he could tell me what could be wrong?
thanks in advance
gerald
|
|
|
|
|
hey, in my program when someone hits the update button, it used to update but the UI would not respond etc. so i use a thread and it works good, but i set the waitcursor before i start the thread but it never stays up, any ideas on how to keep the curors as the wait cursor?
i have have this when the button is pushed:
CWinApp *pApp = (CWinApp*) AfxGetApp();
pApp->DoWaitCursor(true);
AfxBeginThread(startThread, this);
then when the thread is done it posts a message and then i set the cursor back to normal, but the cursor never changes, hope someone can help.
Also how do i go about making a button on the toolbar disabled?
thnkas
luke.
|
|
|
|
|
You will need to create an OnSetCursor handler for your main window that wants to set the wait cursor. You will want to create a variable that holds the current state that the cursor should be in. Then in your OnSetCursor function you should call ::SetCursor();
The reason that you need to do it this way is that every time you move the cursor over your window, a mouse message is generated, then a WM_NCHITTEST message is generated from that, and the WM_SETCURSOR message is then called to allow the mouse cursor to be updated when you move the cursor over the different regions in your window.
DoWaitCursor is only meant for a single function call, or single message handler where the operation could take a long time. However it does not work across message handling boundaries for the reason that I explained above.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
And its confounding me...
I have an array Arr in which I stored the values of 1 row of a database, and the size of this is the number of fields n. Now I want to send this off to a function in a parameter list like
myFunc(Arr[0], Arr[1], Arr[2],....,Arr[n-1])
I cant do a for n =0, n++ type loop since I need them all at once> So what is the way to go here?
Appreciate your help,
ns
|
|
|
|
|
why can't you just pass in the entire array to myFunc? Seems like that what you want....
Just trying to keep the forces of entropy at bay
|
|
|
|
|
The function demands that the parameters be fed in as I showed....I cant change that. Otherwise your idea is great!
Appreciate your help,
ns
|
|
|
|
|
does the function takes a limited or variable number of parameters?
i mean is it like printf ??
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Nope, fixed number of variables
Appreciate your help,
ns
|
|
|
|
|
you could change it from this
myFunc(Arr[0], Arr[1], Arr[2],....,Arr[n-1])
to this
i=0 ;<br />
myFunc(Arr[i], Arr[++i], Arr[++i],....,Arr[++i])
I'm new here, pardon the n00bing
|
|
|
|
|
Thnaks. Welcome to CP
Appreciate your help,
ns
|
|
|
|
|
This doesnt work i fear cos i++ isnt yet evaluated
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
hello!
first: i want to read a .txt file with visual c++. i know there something with fstream, iostram and so on. but i don´t know the details.
second: i want to read different txt files. if i press a button a dialog should open where i can choose a txt-file. how can i program this dialog???
thanks
sunny
|
|
|
|
|
re: first:
create an ifstream object
call open
set file pointer to end using seekg
call tellg to get the number of bytes in the file
allocate that number of chars
set file pointer to beginning using seekg
call read
call close
re: second:
use CFileDialog ... before calling DoModal, fill out the m_ofn structure in the CFileDialog object...
hope that helps...
Just trying to keep the forces of entropy at bay
|
|
|
|
|
i am trying to figure out if the user has 3 keys held down, if so i wanna popup my credits for my program.. the code i see referrences VK_CONTROL, VK_SHIFT, VK_ENTER, but what about normal letters? i tried to override OnKeyDown() but it never gets called.. here is what im using now:
BOOL CAboutDlg::PreTranslateMessage(MSG* pMsg)
{
if(pMsg->message==WM_KEYDOWN)
{
BOOL bS = (GetKeyState(VK_ENTER) & 0x8000);
if (bS)
AfxMessageBox("ding!");
}
return CDialog::PreTranslateMessage(pMsg);
}
thanks for any suggestions!
still a newb.. cut me some slack :P
-dz
|
|
|
|
|
You can pass ASCII code to Get[Async]KeyState.
Tomasz Sowinski -- http://www.shooltz.com
*** Si fractum non sit, noli id reficere. ***
|
|
|
|
|
i tried that.. i found an article on MSDN that said to do that.. i tried using 100 and 115 which are supposed to correspond to 'd' and 's'.. didnt wanna work.. i figured out something else that'll work tho.. thanks a bunch!;)
still a newb.. cut me some slack :P
-dz
|
|
|
|
|
hey dz,
how about posting your thing that works on CP?!
cheers
Adam.
www.beachwizard.com/travelogue[^]
"I spent a lot of my money on booze, birds and fast cars. The rest I just squandered"
George Best.
|
|
|
|
|
I would replace this:
BOOL bS = (GetKeyState(VK_ENTER) & 0x8000);
with this:
BOOL bS = (GetKeyState(VK_ENTER) & 0x10000000);
And yes, it does work with alphabetic characters, but you must use the upper case versions of the characters. Here's a comment from winuser.h:
/* VK_0 thru VK_9 are the same as ASCII '0' thru '9' (0x30 - 0x39) */
/* VK_A thru VK_Z are the same as ASCII 'A' thru 'Z' (0x41 - 0x5A) */
Chris Richardson
|
|
|
|
|
I have several columns in report view. I want to make sure that each column will sort itself if I click its columheader. Is this true? Or is it only the first column that sorts when you click the columnheader? I didnt see this mentioned in the MSDN
Appreciate your help,
ns
|
|
|
|
|
|
I have some CStrings which look like
"1234", "4567" ...so they are numbers in it
"1234efg", efg433" ...so a mix
"199809271234.17:00" which is a date.
I need to do stuff depending on what "type" the CString is: If its all numbers I have to change it into a double or something.
so (I dont see any CString function for this conversion) I'll have to use atoi, strtod etc. Except I have to make sure its totally numeric before I apply these functions.
How to tell if the CString is all numeric?
Appreciate your help,
ns
|
|
|
|
|
I'd use std::ostringstream or strtod (which returns back the pointer where string-to-double conversion has ended).
Tomasz Sowinski -- http://www.shooltz.com
*** Si fractum non sit, noli id reficere. ***
|
|
|
|
|
So if I have *pc = "123456" then I do strtod(pc, &pc,10). I stil dont know which strings I can safely operate on. Do I have to somehow infer from the position of the pointer whether it was the whole length of the string where it ended up (so the whole thing is numbers). If so what exactly tells me the length traversed by the pointer in reaching the location where it breaks off so I can compare it with strlen(original)? Am I missing something or is that a detail that needs dealt with? I have to find out if its all numbers...
Appreciate your help,
ns
|
|
|
|