|
I remember in visual basic there was a function for formatting numbers which seperated the number 1763836382 to 1,763,836,382 or 1.763.836.382 depending on the system settings. is there a function that will do that in c++, or is there just a function that will seperate them with a specified character? (i was thinking sprintf but couldn't find that specific flag for digit grouping)
Thanks in advance.
-Rune Svendsen
|
|
|
|
|
Take a look at the GetNumberFormat in the MSDN. Here's a quote:
"The GetNumberFormat function formats a number string as a number string customized for a specified locale."
So you can use regular sprintf to format the number as a string, and then format that string to the specified locale.
Chris Richardson
|
|
|
|
|
I have a Dialog application with a CTReeCtrl in it . I am buiding an Object Model using the Tree Ctrl but have an XML string associated with each node in the TreeCtrl . I can generate an XML file by traversing all the nodes in the Object Model(TreeCtrl) and just printing the associated Text for a node into a file .
I need to embedd the text information with each node in the TreeCtrl ?
How should I be going about this .
One option is that
For each node in the TreeCtrl i can generate an entry in a look up table that also contains associated text(data). This can be done by generating unique data for each node and by using the SetItemData method for a TreeView Ctrl .
I want to know if there is a better way of doing this !
Please help ( ( confused:
|
|
|
|
|
SetItemData() seems the natural way to go, since you want to associate app specific data with each tree node.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
|
I'm having a problem assinging discontinuous ranges to chart series.
For example the following code works if Xvaluesrange and valuesrange are continuous ranges but not if they are discontinuous:
ActiveChart.SeriesCollection(1).Xvalues = Xvaluesrange
ActiveChart.SeriesCollection(1).values = Yvaluesrange
This gives a "run-time error '1004' Unable to set the Xvalue of the Series class".
From the Excel interface it is possible to assign discontinuous ranges to chart series.
I think this is happening because the Xvalues and Yvalues properties are expecting arrays of values.
If the range I am providing is contiguous, Excel can convert it to an array of values on the fly.
I need to link the data series to the cells. I cannot use constant values neither in Xvaluesrange or YValuesrange.
I cannot use SetSourceData method because it doesn't preserve the existing chart series.
How can I assign discontinuous ranges to new chart series.
Thanks in advance,
Jose.
|
|
|
|
|
Hi
currently I'm developing an app that queries a lot of game servers at a time using UDP. I have a list of about 1000 servers and want to get their information, that's why I need to call SendTo() for every server. If I receive an answer from the server I want to add all necessary information into a CListCtrl .
What's the fastest and safest way to do that? Furthermore I want to set a timeout value (say 1500ms). If the server doesn't answer in that time I want to skip the request and go on with the next server. Currently my code is very crappy and doesn't work very well, i.e. is crashes after about 20 servers (I do not use threads).
I want it that way:
for(int i=0; i<ServerCount; i++)
{
socket.SendTo(...);
(...wait 1500msec for answer)
(next server...)
}
I have overridden my own CSocket so that a member function OnReceiveUDP is called whenever there is data that can be received.
Any suggestions?
Thanks in advance
Greg
modified 12-Sep-18 21:01pm.
|
|
|
|
|
I'm having problems with the window generation of the following code on a Win9x system.
The window is a "child" window that contain a menu and is allowed to be anywhere on the screen, it's not contain
by the parent window. On a win9x system when the window first appears the menu is present but can not be
activated. It seems that is is just drawn and thats it. If I force a redraw the menu goes away entirely.
On a W2K system the menu appears, is active and the entire function of of the window works fine.
I must be missing something ?
Thanks in advance
Tony Teveris
<br />
int iCaptionHite = GetSystemMetrics(SM_CYSIZE) + GetSystemMetrics(SM_CYFRAME);<br />
<br />
CMenu *pMenu = new CMenu;<br />
pMenu->LoadMenu(IDR_VIEW);<br />
<br />
pFW->CreateEx(WS_EX_WINDOWEDGE,<br />
AfxRegisterWndClass(CS_HREDRAW | CS_VREDRAW, AfxGetApp()->LoadStandardCursor(IDC_ARROW),0,AfxGetApp()->LoadIcon(IDI_FONTVIEW)),<br />
"My Test",<br />
WS_OVERLAPPEDWINDOW | WS_POPUPWINDOW | WS_CAPTION | WS_THICKFRAME | WS_VISIBLE ,<br />
iCaptionHite, iCaptionHite, GetSystemMetrics(SM_CXSCREEN)/3, GetSystemMetrics(SM_CYSCREEN)/3, m_pOwner->GetSafeHwnd(), pMenu->GetSafeHmenu(), NULL);<br />
<br />
delete pMenu;<br />
<br />
pFW->UpdateWindow();
Tony Teveris
Gerber Scientific Products
Senior Software Engineer
Phone: 860 648 8151
Fax: 860 648 8214
83 Gerber Road West
South Windsor, CT 06074
|
|
|
|
|
Hi.
Would anyone know how to retrieve a mainframe hWND from a process handle ?
If you use openProcess to get a process handle, how can you find that process's mainframe hWND ?
|
|
|
|
|
You could go loop through the top level windows (children of the desktop)
and check if their process ID matches the one you are after...
See DWORD GetWindowThreadProcessId (HWND hWnd, DWORD *dwID);
I hope this helps,
Iain.
|
|
|
|
|
Hi
I succesfully added new storage into MSWord compound file (and new stream inside this new storage), but the problem is that when I open this doc in MSWord, made some change and save doc, my storage and stream dissapears. I saw application that adds stream(in root storage) which is "word saving proof" but I don't know how to do this. I also encountered strange thing: when I have word doc with stream added by this application, storage and stream added by me doesn't dissapear. I don't know why this happens. Anyone have some idea how to prevent new streams and storages from deleting by Word? Thanks in advance for any hints.
Greetings
Mariusz Popiolek
|
|
|
|
|
How do I extract file/path name from the HDROP passed from WM_DROPFILES??? Couldn't find anything here or MSDN
Nitron
_________________________________________--
message sent on 100% recycled electrons.
|
|
|
|
|
MSDN:
Drag-and-Drop Operations
To support a drag-and-drop operation in a rich edit control, an application must first set an event mask by using the EM_SETEVENTMASK message to allow the EN_DROPFILES notification to be sent to the control's parent window. In the RICHED sample, when the parent window receives this notification, the DragQueryFile function is called to determine how many files have been dropped in the rich edit control. This sample allows the user to drop only one file at a time, so if more than one file has been dropped, the action is disallowed. If the user has dropped only one file, the application queries for the filename, opens the file, and reads it into the rich edit control. As you can see in the following code, the sample allows the user to drop only a TXT or an RTF file:
case WM_NOTIFY:
§
// Is the notification a drop notification?
else if (((LPNMHDR)lParam)->code == EN_DROPFILES)
{
WORD cFiles;
char lpszFile [80];
HANDLE hDrop;
// Get the handle to the drop object.
hDrop = ((ENDROPFILES *)lParam)->hDrop;
// Determine how many objects have been dropped.
cFiles = DragQueryFile (hDrop, 0xFFFF, (LPSTR)NULL, 0);
// If more than one object has been dropped, don't bother.
if (cFiles > 1)
return 0;
// Get the name of the file dropped.
DragQueryFile (hDrop, 0, lpszFile, sizeof (lpszFile));
// Open the file (TXT or RTF).
if (strstr (lpszFile, "TXT"))
OpenTheFile (hWndRichEdit, SF_TEXT, lpszFile);
else if (strstr (lpszFile, "RTF"))
OpenTheFile (hWndRichEdit, SF_RTF, lpszFile);
DragFinish (hDrop);
return 1;
}
return 0L;
break;
This code demonstrates one way that an application can handle a drop operation. Rich edit controls also support OLE drag and drop through the IRichEditOle and IRichEditOleCallback interfaces, which allow objects to be embedded in the control. The subject of embedding objects is beyond the scope of this book, however, so I will not cover it here.
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
|
Nitron wrote:
Couldn't find anything here or MSDN
Hmm, my MSDN (April 2000) says this:
hDrop
Handle to an internal structure describing the dropped files. Pass this handle DragFinish , DragQueryFile , or DragQueryPoint to retrieve information about the dropped files.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I guess I was just looking for something like
hDrop.lpzFileName
Didn't relize I had to read...
Nitron
_________________________________________--
message sent on 100% recycled electrons.
|
|
|
|
|
I want to use CListCtrl's SortItem function. MSDN says there needs to be a comparison function which has to be:
The comparison function must be either a static member of a class or a stand alone function that is not a member of any class.
1. How do I make a static function of a class?
2. If it were a standalone function, I'd declare it in the .h file before the class definition (correct?). Would that be sufficient? Or do I have to specify the prototype in the cpp file before I use it?
Appreciate your help,
ns
|
|
|
|
|
in a .h
class MyClass
{
public:
static int MyFunction(whatever);
};
and then in a .cpp, you implement the function. this function cannot access any non-static member variables of the class.
-c
No matter how fast light travels it finds the darkness has always got there first, and is waiting for it.
-- Terry Pratchett,
|
|
|
|
|
Where is this line supposed to be, from MSDN. In which file is it supposed to be? In the cpp file? If so, in the constructor?
<code>float SavingsAccount::currentRate = 0.00154;</code>
currentRate is a static member variable(declared in the .h file).
Appreciate your help,
ns
|
|
|
|
|
ns wrote:
Where is this line supposed to be,
In the class's .cpp file (theoretically it could be in any .cpp file but the obvious place is that of the class), outside the constructor. It's just a variable initialization.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Hi,
I'm trying to automated power point 2002... I have my own activeX, it Power Point 2002, I can activate it just by pressing double click ( then my ActiveX is up and running...).
BUT... in Power Point 2002, I have to go to Slide Show Mode to do that !!!!, is there anyway to activate it in the normal view ?
Thanks, so long
Braulio
|
|
|
|
|
http://www.codeproject.com/com/OLE_Automation.asp
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Hi,
Sorry but..
Ms Word and Excel models for automation are not that bad, but things like Power Point, or Outlook, are hell !, just give try to detect when really Power Point has been closed ( yeah you will found a sink, but that sink is just executed right before the message that ask you to cancel or save, so...)...
So long
Braulio
|
|
|
|
|
Hi,all,
About the animal's simulation project, i have another problem to
ask. That is,Whether there is any one who can provide a source code, which can be used for generating a specail terrai manually. Of cause 3D is best, but at first step if a 2D contour map can be displayed, that is enough.
thanks a lot!!!
wang
|
|
|
|
|