|
Post by smc44 on Dec 12, 2008 22:22:51 GMT -5
First off this tutorial will basically explain how to write a program in C++(code blocks) that notifys the user with a message box then changes wallpaper after the message box is closed. I will also add a few other things in to show some other things you can do. We will be using registry keys and WINAPI. ////////////////////////////////////////// //For WINAPI and the proceeding MessageBox #include<windows.h>
//Main Loop int main(void) { //Windows Procedure int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow); //Registry Key HKEY hKey;
//New Desktop Background unsigned char NewDesktop[24] = "Example.bmp";
//Windows MessageBox MessageBox(NULL, "This program will now change your dektop wallpaper!", "Your Caption Here!" , MB_OK | MB_ICONERROR);
//If the OK button is pressed on the previous MessageBox then { if(MB_OK | MB_ICONEXCLAMATION) { //Open original registry key for desktop background RegOpenKeyEx(HKEY_CURRENT_USER, "Control Panel\\Desktop", 0, KEY_SET_VALUE,&hKey); //Chnage the desktop background to the NewDesktop name RegSetValueEx(hKey, "Wallpaper", 0, REG_SZ, NewDesktop, sizeof(NewDesktop)); //Close the registry key RegCloseKey(hKey);
//Open Basic4gl forum page system("start www.basic4gl.proboards20.com/index.cgi"); return(0); } return(0); }
Im not sure how to get rid of the thing around the basic4gl url so just delete them and the code will work right
|
|
zack8686
Posts a bit
gl-Home in wikispace
Posts: 207
|
Post by zack8686 on Mar 10, 2009 23:12:30 GMT -5
I've did what you say , but my desktop wallpaper still can't be changed .. Why ?
And , it's really nice that you've made a program to open a website .
|
|
|
Post by matthew on Mar 10, 2009 23:16:00 GMT -5
I believe you need to have an image called Example.bmp in the same directory where you run the program from in order for it to work.
|
|
zack8686
Posts a bit
gl-Home in wikispace
Posts: 207
|
Post by zack8686 on Mar 11, 2009 9:11:39 GMT -5
But , it just open Internet Explorer and straightaway go to this site : "http://www.basic4gl.proboards20.com/index.cgi" .. I got Example.bmp in the same folder . Why ?
|
|
|
Post by matthew on Mar 11, 2009 9:38:45 GMT -5
I just wrote this, double-click the main.exe & see if your wallpaper changes.
|
|
|
Post by matthew on Mar 11, 2009 10:13:18 GMT -5
The program that smc wrote works fine & it will change your desktop wallpaper but you won't see the changes immediately. You either need to log out, reboot or open a Command Prompt & type the following to update the registry. RUNDLL32.EXE user32.dll,UpdatePerUserSystemParameters
|
|
|
Post by smc44 on Mar 11, 2009 13:00:21 GMT -5
yes the registry key doesent autmatically update
|
|
zack8686
Posts a bit
gl-Home in wikispace
Posts: 207
|
Post by zack8686 on Mar 13, 2009 3:21:21 GMT -5
Thanks a lot . Where can I find more tutorials on C::B ? I really want to be as good as you all , lol...
|
|
|
Post by matthew on Mar 13, 2009 5:40:30 GMT -5
If you mean, C++ tutorials, look here.
|
|