|
-
Sep 1st, 2001, 06:26 PM
#1
Thread Starter
Fanatic Member
Icon?
Does anyone know how to change the Icon of the EXE? i mean everytime I compile it, the Icon is the same old DOS ICON

prog_tom
JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
http://physics.sviesoft.com/forum
-
Sep 1st, 2001, 07:12 PM
#2
PowerPoster
You can load the icon from a resource file and then change the following lines for your window class structure:
(I assume that you have an icon called "THEICONNAME" in the resource file. And I also assume that the window cass structure is declared as wc)
PHP Code:
wc.hIcon = MAKEINTRESOURCE(THEICONNAME);
wc.hIconSm = MAKEINTRESOURCE(THEICONNAME);
-
Sep 1st, 2001, 07:47 PM
#3
If it's a console app, then just add an icon to the project, and that will be the icon that the EXE will use.
-
Sep 1st, 2001, 08:50 PM
#4
Frenzied Member
Megatron:
Doesn't work for me
-
Sep 1st, 2001, 10:12 PM
#5
Thread Starter
Fanatic Member
Not what I meant
Hi Abdul, I meant the Icon displayed on the EXE file. Not in the program... Also Megatron, I'm creating a Win32 App. Not Console.
Please have a look at this code:
Code:
//Sviesoft Corporation(r)
//Copyright(c) 1999 - 2001
//All Rights Reserved
//
//Thanks to God, my Mom and the people
//that have supported me all these years
//
//God Bless you all, Amen
#include <windows.h>
const char tzID[]="myWindowClass";
HINSTANCE hInst;
#define BUT1 1
#define TEX1 2
LRESULT CALLBACK WndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam){
switch(msg){
case WM_CREATE:
CreateWindowEx(NULL,"edit","",WS_CHILD|WS_VISIBLE,100,40,80,20,hwnd,(HMENU)TEX1,hInst,NULL);
CreateWindowEx(NULL,"button","Submit",WS_CHILD|WS_VISIBLE,100,100,80,20,hwnd,(HMENU)BUT1,hInst,NULL);
break;
case WM_COMMAND:
switch(LOWORD(wParam)){
case BUT1:
MessageBox(hwnd,"You clicked","",0);
return 0;
break;
case TEX1:
MessageBox(hwnd,"Type in your name","",0);
return 0;
break;
}
case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,msg,wParam,lParam);
}
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow){
WNDCLASSEX tz;
HWND hwnd;
MSG Msg;
tz.cbSize=sizeof(WNDCLASSEX);
tz.style=0;
tz.lpfnWndProc=WndProc;
tz.cbClsExtra=0;
tz.cbWndExtra=0;
tz.hInstance=hInstance;
tz.hIcon=LoadIcon(NULL,IDI_APPLICATION);
tz.hCursor=LoadCursor(NULL,IDC_ARROW);
tz.hbrBackground=(HBRUSH)(COLOR_WINDOW+8);
tz.lpszClassName=tzID;
tz.lpszMenuName=NULL;
tz.hIconSm=LoadIcon(NULL,IDI_APPLICATION);
if(!RegisterClassEx(&tz)){
return 0;
}
hwnd=CreateWindowEx(WS_EX_CLIENTEDGE,tzID,"Welcome!",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,500,300,NULL,NULL,hInstance,NULL);
if(hwnd==NULL){
return 0;
}
ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&Msg,NULL,0,0)){
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}
When I click on the "edit"(TextBox), it pops out MessageBox twice. How to change it to once? Do you know how to get the Text in the "edit"?

prog_tom
JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
http://physics.sviesoft.com/forum
-
Sep 1st, 2001, 10:20 PM
#6
Re: Not what I meant
Originally posted by prog_tom
Hi Abdul, I meant the Icon displayed on the EXE file. Not in the program...
it should do it for both, it does for me.
Laugh, and the world laughs with you. Cry, and you just water down your vodka.
Take credit, not responsibility
-
Sep 1st, 2001, 10:22 PM
#7
PowerPoster
you have
return 0;
break;
at the end of each case statement. Try erasing one of those lines and then see if you get two messages.
Try the following code that shows a messagebox with the editbox text in it:
PHP Code:
char edtext[100];
GetDlgItemText(hwnd, TEX1, edtext, GetWindowTextLength(GetDlgItem(hwnd, TEX1)) + 1);
MessageBox(NULL,edtext,"The text",MB_OK);
-
Sep 1st, 2001, 10:22 PM
#8
PowerPoster
Re: Re: Not what I meant
Originally posted by crptcblade
it should do it for both, it does for me.
Yes
-
Sep 2nd, 2001, 01:24 AM
#9
Thread Starter
Fanatic Member
Both?
Yeah I removed:
But each time I clicked Either Button or Edit, it will pop up expressions for both.
I only want like one for one...

prog_tom
JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
http://physics.sviesoft.com/forum
-
Sep 2nd, 2001, 05:56 AM
#10
PowerPoster
that is wierd. I only get two message boxes with the editbox. I don't know if there is any other way to do so without subclassing the editbox. I think that you are getting two message boxes because of one "Down" and one "Up" event on the editbox.
Here is the subclassing thing that only shows one messagebox when the mouse is down:
PHP Code:
//Sviesoft Corporation(r)
//Copyright(c) 1999 - 2001
//All Rights Reserved
//
//Thanks to God, my Mom and the people
//that have supported me all these years
//
//God Bless you all, Amen
#include <windows.h>
const char tzID[]="myWindowClass";
HINSTANCE hInst;
WNDPROC wOldProc;
#define BUT1 1
#define TEX1 2
LRESULT CALLBACK SubClassText(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam);
LRESULT CALLBACK WndProc(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
switch(msg){
case WM_CREATE:
CreateWindowEx(WS_EX_CLIENTEDGE,"edit","",WS_CHILD|WS_VISIBLE,100,40,80,20,hwnd,(HMENU)TEX1,hInst,NULL);
CreateWindowEx(NULL,"button","Submit",WS_CHILD|WS_VISIBLE,100,100,80,20,hwnd,(HMENU)BUT1,hInst,NULL);
wOldProc = (WNDPROC)SetWindowLong(GetDlgItem(hwnd, TEX1), GWL_WNDPROC, (LONG)SubClassText);
break;
case WM_COMMAND:
switch(LOWORD(wParam)){
case BUT1:
MessageBox(hwnd,"You clicked","",0);
return 0;
case TEX1:
return 0;
}
return 0;
case WM_CLOSE:
SetWindowLong(GetDlgItem(hwnd, TEX1), GWL_WNDPROC, (LONG)wOldProc);
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd,msg,wParam,lParam);
}
return 0;
}
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow){
WNDCLASSEX tz;
HWND hwnd;
MSG Msg;
tz.cbSize=sizeof(WNDCLASSEX);
tz.style=0;
tz.lpfnWndProc=WndProc;
tz.cbClsExtra=0;
tz.cbWndExtra=0;
tz.hInstance=hInstance;
tz.hIcon=LoadIcon(NULL,IDI_APPLICATION);
tz.hCursor=LoadCursor(NULL,IDC_ARROW);
tz.hbrBackground=(HBRUSH)(COLOR_WINDOW+8);
tz.lpszClassName=tzID;
tz.lpszMenuName=NULL;
tz.hIconSm=LoadIcon(NULL,IDI_APPLICATION);
if(!RegisterClassEx(&tz)){
return 0;
}
hwnd=CreateWindowEx(WS_EX_CLIENTEDGE,tzID,"Welcome!",WS_OVERLAPPEDWINDOW,CW_USEDEFAULT,CW_USEDEFAULT,500,300,NULL,NULL,hInstance,NULL);
if(hwnd==NULL){
return 0;
}
ShowWindow(hwnd,nCmdShow);
UpdateWindow(hwnd);
while(GetMessage(&Msg,NULL,0,0)){
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}
//--------------------------------------------------------------------------------
LRESULT CALLBACK SubClassText(HWND hwnd,UINT msg,WPARAM wParam,LPARAM lParam)
{
switch(msg)
{
case WM_LBUTTONDOWN:
MessageBox(NULL,"You clicked to editbox","Hi",MB_OK);
return 0;
}
return CallWindowProc(wOldProc, hwnd, msg, wParam, lParam);
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|