|
To load the bitmap from a file at runtime, please use the code
HANDLE handle = LoadImage( AfxGetInstanceHandle(),
"filname.bmp",
IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
CBitmap* pBmp = CBitmap::FromHandle((HBITMAP)handle);
Now you loaded the bitmap from the file and you got a pointer of CBitmap class. And its now ready to use.
Isn't it simple ?
Regards,
Jijo.
________________________________
Yesterday is history,
Tomorrow is a mystery,
But today is a present.
|
|
|
|
|
Hi...
ThankYou for a valuable suggestion...how should i add that bitmap to a dialog..I used LoadBitmap() in OnInitDialog()...but its not working....
|
|
|
|
|
Use a CStatic control and use the SetBitmap() method.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
The LoadBitmap () function does not display the BMP to the dialog, It just load the bitmap from the file and gives us a handle. And from that handle we can make a CBitmap* and use.
And do you want to make the bitmap as your dialogs background pic ? if its the prblm the solution is below.
1. First add a member variable "CBitmap* pBmp" to your dialog class.
2. Then in the OnInitDialog () function of the dialog, add the following lines.
HANDLE handle = LoadImage( AfxGetInstanceHandle(),
"imagename.bmp",
IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
pBmp = CBitmap::FromHandle((HBITMAP)handle);
3. Now in the OnPaint () function of the dialog, add these code,
CPaintDC dc(this);
CDC memdc;
memdc.CreateCompatibleDC (&dc);
memdc.SelectObject (*pBmp);
dc.BitBlt (0, 0, WidthOfBMP,HeightOfBMP,&memdc,0,0,SRCCOPY);
thats all. Now the bitmap get painted in your windows background. And if its not the prblm feel free to ask.
Isn't it simple ?
Regards,
Jijo.
________________________________
Yesterday is history,
Tomorrow is a mystery,
But today is a present.
|
|
|
|
|
Thanks a lot Jijo....Its really simple and it worked...
|
|
|
|
|
i've tried FindWindow(), GetWindow() that kind of function call and try to get the handle of the window explorer and then destroy it, but failed. anyone have any idea how to do it?? Thanks.
|
|
|
|
|
use TerminateProcess or ExitProcess
|
|
|
|
|
please try this method.
1. First get the list of all process in the system. Use the function - CreateToolhelp32Snapshot ().
2. Then traverse through the list by using Process32First() and Process32Next using structure PROCESSENTRY32.
3. Then by traversing find the process of the windows explorer. User "szExeFile" member of PROCESSENTRY32 structure for Identifing the Process of explorer. Its the "path + filename" of the exe of the process. For us the path of explorer is - Get the value of the environment variable - <windir> + "explorer.exe". Because explorer.exe lies in the windows system folder.
4. Now get the handle of the explorer process using the OpenProcess () function. Pass the PROCESSENTRY32.th32ProcessID as the dwProcessId parameter of the OpenProcess () function. Now you get the handle as the return of the OpenProcess () function.
5. Now you got the handle. The rest is simple - Call TerminateProcess () function using the handle and the process will get terminated.
simple. isn't it ?
NB: Read thoroughly about each and every function ur using for this in MSDN. Many of the function are asking the privilage you need when you play on processes. So if you dont have necessery privilage, the Termination wont work.
Regards,
Jijo.
________________________________
Yesterday is history,
Tomorrow is a mystery,
But today is a present.
|
|
|
|
|
Does any know how to convert a string to an int or float using the Win32 locale functions ?
I can get the GetNumberFormat to work great for me in converting an int/float to a string, but I'd like to go the other way, and I don't see any support for this.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
|
|
|
|
|
atoi and atof
?
#include <stdlib.h>
#include <stdio.h>
int main( void )
{
char *s; double x; int i; long l;
s = " -2309.12E-15"; /* Test of atof */
x = atof( s );
printf( "atof test: \"%s\"; float: %e\n", s, x );
s = "7.8912654773d210"; /* Test of atof */
x = atof( s );
printf( "atof test: \"%s\"; float: %e\n", s, x );
s = " -9885 pigs"; /* Test of atoi */
i = atoi( s );
printf( "atoi test: \"%s\"; integer: %d\n", s, i );
s = "98854 dollars"; /* Test of atol */
l = atol( s );
printf( "atol test: \"%s\"; long: %ld\n", s, l );
}
Bryce
---
Publitor, making Pubmed easy.
http://www.sohocode.com/publitor
|
|
|
|
|
Yeah, but like the man said, he wants to use locales, In some countries, a comma is used instead of a point between numbers.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
couldnt he query the locale settings for number separator and modify the above code?
"there is no spoon" biz stuff about me
|
|
|
|
|
Yeah, he may need to. Or use a stream perhaps ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
I'd like to completetly avoid using the STL for this, the IOStreams and locales are pretty iffy in terms of various implementations completeness.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
|
|
|
|
|
You need to compile on more than one compiler ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Yes, more than likely, and even if people use VC++ they may choose to use different STL Implementations, and the locale's support is the weakest part of the IOStream impl - some are good some are incomplete
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
|
|
|
|
|
Would it make sense if I got the various separator(s) characters from Win32, and then remove all the separators, get the decimal char from Win32 and replace it with a '.' char and then use the atof or atoi functions ?
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
|
|
|
|
|
Yeah, I suppose that would be a brute force, inelegant way of doing it. It may well be your best bet, but it would sure be nicer if the code in question knew what it was looking at, if you see what I mean.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Yeah, but I can't think of any other reliable way to do it - a pity the Win32 locale functions don't handle this.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
|
|
|
|
|
Per MSDN, atof() will do this as it respects the locale settings. You may need to call setlocale() first, however. I tried this and it indeed works (i.e., converted "123,45" to 123.45).
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
Whats the easiest way to download a web page. I dont want to view it. I just want to download to my desktop for example, then I will process it.
Like, for instance, I want to download www.mywebpage.com\test.html (just an example) to
my desktop.
|
|
|
|
|
Right click on the link, Save Target As...
"Another day done - All targets met; all systems fully operational; all customers satisfied; all staff keen and well motivated; all pigs fed and ready to fly" - Jennie A.
|
|
|
|
|
Thanks for the reply. I shouldve said that I need to download it using VC++.
I'm not familiar with sockets and it seems simple to do but it may not be.
|
|
|
|
|
|