|
Try something like this. I use code very similar to this all the time. NOTE I have not tested the negative double (the insertion of the - sign may need to be adjusted.
void convertMyDoubleToString(double myDouble,int precision,CString& result) const{
char* buffer;
int dec;
int sign;
size_t i;
buffer = _fcvt(myDouble,precision,&dec,&sign);
for (i=strlen(buffer)-1;i>(size_t)sign;i--){
if (i == dec){
buffer[i+1] = buffer[i];
buffer[i] = '.';
break;
}else{
buffer[i+1] = buffer[i];
}
}
result = buffer;
if (myDouble >= 0 && myDouble < 1){
result = CString("0.") + result.Left(result.GetLength()-1);
}else if (myDouble < 0 && res > 1){
result = CString("-0.") + result; //MAY NEED TO ADJUST THIS
}else if (myDouble <= 1){
result = CString("-") + result; //MAY NEED TO ADJUST THIS
}
}
|
|
|
|
|
Try
sprintf(buffer,"%.5lf",dNum);
(remark the l between 5 and f)
SkyWalker
|
|
|
|
|
Is there a way I can find out if a given path is on a drive on the user's PC vs. a remote drive on a LAN. The path could be a UNC, a mapped drive, a local drive or no drive spec. The UNC could still be the local machine.
Suggestions?
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
Is PathIsNetworkPath() close? There are other Pathxxx() functions, too.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Thanks David, I didn't think to look at the Shell functions. I'll give this a try.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
I realize its not the stl forum but theres no traffic in there:
I want to get the index of the min element and am doing:
std::vector<int>::iterator start,end, location ;
start = m_distances.begin();
end = m_distances.end();
location = min_element(start,end);
qDebug("%d min val %d %d",*location, *start, *end);
int index = location - start;
but it doesnt work. I always get 181 as the index.
??
Thanks,
sb
|
|
|
|
|
Hi,
has anyone done the above before in C++? I need to do it and don't know where to start...
Thanks,
Pia
|
|
|
|
|
Start by having a look at GDI+. You'll find articles here and at MS.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
There are several articles at http://www.codeproject.com/bitmap/[^] that cover the topic. The most light weight ones being the ones that wrap the IPicture interface.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
Hey all
My question is how to find a child window!
well, I know that I can use FindWindow("hwndclass", NULL); but how to find a child window of a program? I tried using FindWindow() but it couldn't recognize the child window... is there any way?
thanks in advance
|
|
|
|
|
EnumChildWindows()?
Artificial intelligence is no match for natural
stupidity.
|
|
|
|
|
|
After Using the FindWindow() ,For enumerating Child Window use FindWindowEx() .
if you need,I will Provide you code for Enumerting the Desktop Windows.
"I Think this Will Help"
<h5
alok gupta="" <br=""> visit me at http://www.thisisalok.tk
|
|
|
|
|
FindWindowEx allows you to specify a parent handle, and will search only for children of that parent window.
So you find the parent window, then call FindWindowEx using the parent window handle as the starting search point.
There is one VERY important caveat:
FindWindowEx will ONLY find FIRST generation children.
Suppose for example, your top level window is a dialog box. The Dialog has a frame control. The window you want to find is a child of the frame.
Calling FindWindowEx using the parent will find the frame. But it will not find your desired window, because it only searches direct children.
So your strategy in this case would be:
1) Get dialog handle.
2) Use dialog handle as parent and find handle to the frame.
3) Then use the frame handle, NOT the dialog handle, as the new parent and continue the search.
This will now find your target because it is a direct child of the frame, not the dialog.
Because windows hierarchies can be complex, you need to use a tool like Spy which can show the relationships of a window. Then base you search strategy based on how Spy shows you the windows are related.
Hope this helps,
Robert
|
|
|
|
|
Thanks alot for your replaies....
but does this also work with a popup window?
I mean, many programs have option window... let's take Yahoo for example, if I click on option from the menu then a popup window will come and disable the main yahoo list, so can I also use FindWindowEx to find this popup window?
thanks alot
|
|
|
|
|
Well, usually the use of FindWindowEx implies that you are finding and possibly manipulating windows in a program external to your own program, because you should already inherently know how to find all windows your own program creates.
So, assuming you are doing what I think you are doing, the answer is yes, because the popup is modal to the browser window that spawned it, but it is not modal to your own program. So yes, you can still execute code and should be able to find it. Again, use Spy to help you design the strategy to find the popup.
I have a program that creates a browser window and then navigates to a site page that displays a popup modal dialog. I have no problems finding the login dialog, and entering the login automatically.
So I think the answer to your question is yes, unless you are doing something really weird.
Robert
|
|
|
|
|
well...
when I try using spy++ then I found that the class of the windows is #32770 (Dialog) and the window caption is option, and when I use FindWindow() and use SendMessage() to close it, nothing happen!
HWND optionwindow =::FindWindow(NULL, "option");
or
HWND optionwindow =::FindWindow("#32770", NULL);
or even
HWND optionwindow =::FindWindow("#32770", "option");
and
::SendMessage(optionwindow, WM_CLOSE, 0, 0);
but not working!
any help thanks?
|
|
|
|
|
I'm writing again since nobody has answered my previous post about the strange error I get under win98/ME and 2000 (debug assertion failure at daocore.cpp @ line 453, but the code actually works perfect under winxp sp2.
CDaoDatabase db;<br />
CDirectory dir;<br />
CString strDb = dir.GetCurDir() + _T("db.udb");<br />
<br />
if(GetFileAttributes(strDb) == 0xFFFFFFFF)<br />
{<br />
try{<br />
db.Create(strDb);<br />
CString strSQL;<br />
strSQL = _T("CREATE TABLE table (id COUNTER);");<br />
db.Execute(strSQL);<br />
db.Close();<br />
} catch (CDaoException *e)<br />
{<br />
e->ReportError();<br />
e->Delete();<br />
}<br />
}
Please help
|
|
|
|
|
I forgot to mention that it fails on the target machine (client), so may be it's something with redistribution or what?
|
|
|
|
|
|
The error is
debug assertion failed
File: daocore.cpp
Line: 453
the error is "there is no error message", it's so weird!!!!
|
|
|
|
|
I see that it's saying that it's failing on an ASSERT(FALSE) line. I'd go to the actual file, up a few lines where it says: BOOL bRetCode = FALSE; and put a breakpoint there.
My articles
www.stillwaterexpress.com
BlackDice
|
|
|
|
|
I am using modaless CDialog
What is the or is there a command to update dialog window when you set data with new values? Or do I need to delete the old one and recreate new one?
I am trying to implement so that I can right click roll over objects on the screen and the dialog will update with new information, and dialog would be terminated when right click is released
|
|
|
|
|
UpdateData() assuming you are using MFC. Otherwise you'll need to repopulate the controls yourself.
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
I tried UpdateData() and it didn't work
Although SetWindowText changes the title
|
|
|
|