|
Are you updating the toolbar and statusbar during normal windows operations like moving and resizing of your main window? Do you have a child window in your main window or do you use the 'free' area of your main window for display of your data?
BTW please put your code snippets between <pre> tags so it is more readable, like this:
static HWND hWndStatusBar;
hWndStatusBar = CreateWindowEx(
0, STATUSCLASSNAME, (LPCTSTR) NULL, WS_CHILD | WS_VISIBLE, 0, 0, 0, 0, hWndParent, NULL, hInst, NULL);
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Hi, thanks for your help.
For the first question, I'm not updating toolbar and statusbar. As they are both child windows of main window. I expected they might be automatically updated by main window.
As for your second question, I use the "free" area of main window and there is no child window in main window.
Do I suggest me to either update toolbar and statusbar every time the main window is updated, or create a child window inside main window?
I guess the issue might result from the inproper layout that the toolbar and statusbar are overlayed on the client area of main window, and I use InvalidateRect(hwndParent, NULL, FALSE) to update the client area. But the toolbar and statusbar are not automatically updated by InvalidateRect. Which way is better? or is there any other method to fix the issue? I'm looking forward to your further help.
|
|
|
|
|
Lianqing wrote: I use InvalidateRect(hwndParent, NULL, FALSE) to update the client area.
Which means you paint over the entire client area of your window including the space taken by the toolbar and statusbar. This is not the best way to do it. Whether you use a client window or the client space of the main window you need to adjust your sizes to take account of the toolbar and statusbar. The top left of your client space needs to be adjusted by the height of the toolbar and its height by the height of the statusbar. It's generally better to follow the Windows model and use a client window.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
I had follow code :
double dbl = 24.000560700;
CString sTemp,sDecimal;
sTemp.Format(_T("%0.16f"),dbl);
SetWindowText(sTemp);
and result is 24.0005607000000010 ... not 24.000560700, why ?
|
|
|
|
|
because the number cannot be precisely represented in binary, and when it gets printed out, the value will be displayed with that "error".
See this : http://support.microsoft.com/kb/42980[^]
Watched code never compiles.
|
|
|
|
|
Why does this question keep coming up? ...please do a search before posting questions... I'm sure we've answered this about 10-20 times in a year's time frame...
|
|
|
|
|
Because you asked for 16 digits, it gave you 16 digits.
The "imprecision" is in producing the OUTPUT, the conversion of the binary / computer representation of the number into the string of characters that you display. This is true regardless of whether it is you printing the value or the debugger displaying it for you. Both processes need to take the binary value and convert it to a string of characters for your eyes.
Computer binary representations (Base 2) and printed represetnations (in Base 10) are inherently incompatible and can only be approximated. You control the approximation with the format specifier for how many digits you want to see.
You have also made a basic assumption that is also flawed. You assume this program statement produces a "precise" value:
double dbl = 24.000560700; when in fact, the compiler has to take this character representation of a number, convert it from base 10 to the binary representation of a floating point number, base 2, and put it into the object file to be included in the program. Because of the what I said above, conversion from text to binary form (compilation) or from binary form to text (printf) each provide some level of "imprecision" or "approximation" that varies in the least significant digits, as you've discovered.
|
|
|
|
|
"%0.16f" means there will be 16 digits after the "." for result.
"%0.9f" is what you need!
|
|
|
|
|
Because the double data type is a convenient approximate representation (see here, it is quite formative)[^]) of real numbers. Computers memory is finite, it cannot map infinite sets like real numbers (or even natural numbers).
Veni, vidi, vici.
|
|
|
|
|
|
Yes, but I don't know always how many decimal exist ...
|
|
|
|
|
You might as well ask "How many angels can dance on the head of a pin?".
You really need to read the article already linked http://support.microsoft.com/kb/42980[^] and embrace the idea that a "Binary Computer" cannot precisely represent every possible "Decimal Digit" that exists for floating point numbers. It is a fact of life.
Rather than try to figure out how many "decimals exist", you just need to determine "how many you care about". 6, 12, 18 are a pretty common need, unless you are doing planetary orbital calculations or high energy physics.
|
|
|
|
|
Flaviu2 wrote: Yes, but I don't know always how many decimal exist ...
This is how many decimals exist when storing the value into a float: 1E300000
If we encode that value into html: ∞
Best Wishes,
-David Delaune
|
|
|
|
|
Darkman's SWFLIB v1.1, release date - July 4, 2006 and he said "the future releases will increase the functionality of this library", see:
http://www.codeproject.com/KB/audio-video/SWFLIB.aspx?display=PrintAll
But i can't find any new messages about SWFLIB v1.2 or higher, do you know where we can get it or get a replacement lib?
|
|
|
|
|
SimonCommon wrote: do you know where we can get it or get a replacement lib?
Nope, because the best way to obtain such a info is posting the request at the article's own thread.
Veni, vidi, vici.
|
|
|
|
|
I want to navigate to a web page (with IE) and close IE after that ... here is the code :
STARTUPINFO siStartupInfo;
PROCESS_INFORMATION piProcessInfo;
memset(&siStartupInfo, 0, sizeof(siStartupInfo));
memset(&piProcessInfo, 0, sizeof(piProcessInfo));
siStartupInfo.cb = sizeof(siStartupInfo);
if(! CreateProcess(NULL,
_T("C:\\Program Files\\Internet Explorer\\iexplore.exe http://www.somepage.com"),
0,
0,
NULL,
CREATE_DEFAULT_ERROR_MODE,
0,
0,
&siStartupInfo,
&piProcessInfo))
{
CString sError;
sError.Format(_T("Create process error (%d)\n"),GetLastError());
SetWindowText(sError);
}
else
{
SetWindowText(_T("OK"));
WaitForSingleObject(piProcessInfo.hProcess,2000);
CloseHandle(piProcessInfo.hProcess);
CloseHandle(piProcessInfo.hThread);
}
the code from above open the web page ... but does not close IE after ... why ? What I'm doing wrong ?
|
|
|
|
|
From the platform SDK:
The CreateProcess function creates a new process, which runs independently of the creating process.
Thus, the new process terminates when you close it as any other process using the Exit menu item, close button, or pressing Alt-F4.
You may use the PROCESS_INFORMATION structure elements to identify the IE process and send it a termination message (e.g. by sending WM_CLOSE to the main window handle).
|
|
|
|
|
Thank you, I will work around ....
|
|
|
|
|
I saw that if I want to close an window, I need hWnd of that window ... but I don't know how can I get that if I have STARTUPINFO and PROCESS_INFORMATION structure ... none of this can achieve handle of new created window ... I'm pushing my luck ? Any hint will be very appreciated !
|
|
|
|
|
Have you tried:
PostThreadMessage(piProcessInfo.dwThreadId, WM_CLOSE, ...);
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
I'd like to ask what is probably a stupid question. Why would you "popup" a browser, have it navigate to a web page, only to close the browser.
Presumably you went to the page so that the user can see the output yet you want to take it down before knowing they've read it.
You want to tear down the process before knowing if the browser access to the web page even worked (network delays may cause the web page to not respond quickly) so if your URL is "transaction related", you never know if it worked or not.
You don't even know if the URL worked or if you got some browser message saying that the site was inaccessible.
Seems to me that you're using the wrong tool for the job, you might want to use the WinInet interface to read / write URLs programatically and process the output yourself.
Unless, of course, the web site is meant to display information to the user, in which case we're back to asking why tear it down before they get a chance to read it?
|
|
|
|
|
In fact, I want to execute an command to a some server :
www.somesite.com/index.php?command=12
and for that, would be proper to start IE browser in hidden mode ... perhaps I'm doing in worng way ??
|
|
|
|
|
Starting the browser is the wrong way. You can use the Wininet API to connect to the server.
There are some examples here at CP. I picked three from the search results:
CHttpClient - A Helper Class Using WinInet [^]
Simple HTTP Client using WININET [^]
AmHttpUtilities [^]
|
|
|
|
|
Yes, you are doing it the wrong way. You are just "firing and forgetting" when you use IE to do this, your program has no idea if it worked at all.
In addition to what Jochen said, the sequence of calls to the WinINet APIs that can simulate a POST operation is:
1) InternetOpen() to begin communication
2) InternetConnect() to connect to the web site
3) HttpOpenRequest() to do a POST to the script
4) HttpSendRequest() to send the data being "posted"
5) InternetReadFile() to receive any optional output the script produces (status)
6) InternetCloseHandle() to close the various handles opened by the previous steps.
You can look all these up on MSDN. Get this to work and you've learned a lot of useful stuff.
|
|
|
|
|
 I want to execute this address :
// http://www.somesite.com/index.php?page=projects&sub=der_download_port
Here is my trial:
CString CTestWinInetDoc::SendRequest()
{
HINTERNET hSession = InternetOpen(_T("TestWinInet"),
INTERNET_OPEN_TYPE_DIRECT,NULL,NULL,0L);
if(hSession == NULL)return _T("Internet session handle invalid");
HINTERNET hConnect = InternetConnect(hSession,
_T("http://www.somesite.com"),
INTERNET_DEFAULT_HTTP_PORT,NULL,NULL,
INTERNET_SERVICE_HTTP,0,0);
if(hConnect == NULL)
{
InternetCloseHandle(hSession);
return _T("Internet connect handle invalid");
}
HINTERNET hRequest = HttpOpenRequest(hConnect, NULL,
_T("index.php?page=projects&sub=der_download_port"), NULL, NULL, 0, INTERNET_FLAG_RELOAD, 0);
if(hRequest == NULL)
{
InternetCloseHandle(hSession);
InternetCloseHandle(hConnect);
return _T("Internet request handle invalid");
}
BOOL bSent = HttpSendRequest(hRequest, NULL, 0,
NULL, 0);
if(! bSent)
{
InternetCloseHandle(hSession);
InternetCloseHandle(hConnect);
InternetCloseHandle(hRequest);
return _T("Can not sent requested data");
}
InternetCloseHandle(hSession);
InternetCloseHandle(hConnect);
InternetCloseHandle(hRequest);
return _T("Success !");
}
but this code seems to do nothing ... what is wrong here ?
|
|
|
|
|