Home > OS >  Cannot update icon win32API programming!
Cannot update icon win32API programming!

Time:10-09

Custom icon can't display all the time, however, in the same way a custom cursor shows that there is no issue, beginners win32, give advice or comments please everybody!
#include
#include
# include "resource. H"

//callback function
LRESULT a CALLBACK MyWndProc (HWND HWND, UINT uMsg, WPARAM WPARAM, LPARAM IParam);

Int WINAPI WinMain (HINSTANCE HINSTANCE, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
//the first parameter window handle, and the second parameter window handle, the third long pointer to the string, the fourth is an INT type
{
//window class instance objects
WNDCLASS WND;
//define receive window handle
The HWND hwin;
//receive system messages
MSG MSG.
//members style window type
WND. Style=CS_HREDRAW | CS_VREDRAW;

//message handler ipfnWndProc (callback function)
WND. LpfnWndProc=MyWndProc;
//reserve value, fu empty
WND. CbClsExtra=0;
WND. CbWndExtra=0;
//window icon hIcon IDI_ICON1
//WND. HIcon=LoadIcon (NULL, IDI_APPLICATION);
WND. HIcon=LoadIcon (hInstance, MAKEINTRESOURCE (IDI_ICON1));
//mouse state hCursor
WND. HCursor=LoadCursor (NULL, IDC_ARROW);
//set hbrBackground, need to use a brush, note need to convert HBRUSH
WND. HbrBackground=(HBRUSH) GetStockObject (WHITE_BRUSH);
//do not use the
WND. LpszMenuName=NULL;
//window name lpszClassName
WND. LpszClassName=TEXT (" the first window ");
//window handle
WND. HInstance=hInstance;
//determine whether registered success

if (! RegisterClass (& amp; WND))
{
MessageBox (NULL, TEXT (" register fail "), TEXT (" errorMsg "), 0).
return 0;
}
//create a window handle
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

The following is a header file contents:
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
//{{NO_DEPENDENCIES}}
//Microsoft Visual c + + generated include file,
//for the Resource. Rc use
//
# define IDI_ICON1 101

//Next to the default values for the new objects
//
# ifdef APSTUDIO_INVOKED
# # ifndef APSTUDIO_READONLY_SYMBOLS
# define _APS_NEXT_RESOURCE_VALUE 102
# define _APS_NEXT_COMMAND_VALUE 40001
# define _APS_NEXT_CONTROL_VALUE 1001
# define _APS_NEXT_SYMED_VALUE 101
# endif
# endif
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
The following is a resource. The content of the rc:
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
//Microsoft Visual c + + generated resource script.
//
# include "resource. H"

# define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
//Generated from the TEXTINCLUDE 2 resource.
//
# include "winres. H"

/////////////////////////////////////////////////////////////////////////////
# undef APSTUDIO_READONLY_SYMBOLS

/////////////////////////////////////////////////////////////////////////////
//Chinese (simplified Chinese) resources

# if! Defined (AFX_RESOURCE_DLL) | | defined (AFX_TARG_CHS)
LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED

# ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
//TEXTINCLUDE
//

1 TEXTINCLUDE
The BEGIN
"Resource. H \ 0
END

TEXTINCLUDE 2
The BEGIN
"# include" "winres. H" "\ r \ n
""\ 0
"END

3 TEXTINCLUDE
The BEGIN
"The \ r \ n
""\ 0
"END

# endif//APSTUDIO_INVOKED


/////////////////////////////////////////////////////////////////////////////
//
//Icon
//

//Icon with the lowest ID value placed first to ensure the application Icon
//remains consistent on all systems.
IDI_ICON1 ICON "icon1. Ico
"# endif//Chinese (simplified Chinese) resources
/////////////////////////////////////////////////////////////////////////////



# # ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
//Generated from the TEXTINCLUDE 3 resource.
//


/////////////////////////////////////////////////////////////////////////////
# endif//not APSTUDIO_INVOKED

CodePudding user response:

For two days, no one see?
  • Related