我用窗户 a子建立了基本应用程序。 这只是一个小窗口。 我从主要职能开始,接手,创造我的窗口等。 一切都做的是罚款。 然而,我面临的问题是,我的习俗icon将不会在窗口顶端或任务栏上展示,它只是显示一个窗口的缺省情景。 然而,这确实表明我的实际可点击的外壳是一角。 我利用善待提供资源,并创造所有4个系数,以便它能够拥有适当的规模。 接手
HICON hMyIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));
I then used WNDCLASSEX and gave the handle to both hIcon and hIconsm. If there is anything that could cause it to not show up in the corner or task bar, please help.
#include <Windows.h>
#include <iostream>
#include "resource.h"
//globals
MSG msg;
HWND hwndwnd;
HICON hMyIcon;
//Windows Procedure
LRESULT CALLBACK WndProc( HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam )
{
switch ( message )
{
case WM_CLOSE:
exit( 0 );
break;
case WM_CREATE:
SendMessage(hwndwnd,WM_SETICON,ICON_SMALL,(LPARAM)hMyIcon);
break;
}
return DefWindowProc( hwnd, message, wparam, lparam );
}
int main(int ArgumentNum, char *arg[])
{
//get instance
char title[500];
GetConsoleTitleA( title, 500 );
HWND hwndConsole = FindWindowA( NULL, title );
HINSTANCE hInstance = (HINSTANCE)GetWindowLongPtr(hwndConsole, GWLP_HINSTANCE);
//get icon handle
hMyIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_ICON1));
if (hMyIcon == NULL)
{
std::cout<< "NULL
";
}
//create & register class
WNDCLASSEX wc;
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_DROPSHADOW;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = hMyIcon;
wc.hCursor = LoadCursor(hInstance, IDC_ARROW);
wc.hbrBackground = (HBRUSH)GetStockObject( WHITE_BRUSH );
wc.lpszMenuName = 0;
wc.lpszClassName = "Jacob";
wc.hIconSm = hMyIcon;
RegisterClassEx(&wc);
//create window
hwndwnd = CreateWindow("Jacob", "My Window",
WS_OVERLAPPEDWINDOW, 520, 20, 300, 300, NULL, NULL, hInstance, NULL);
//Tried sendmessage here as well
//SendMessage(hwndwnd,WM_SETICON,ICON_SMALL,(LPARAM)hMyIcon);
ShowWindow( hwndwnd, SW_SHOWNORMAL);
UpdateWindow( hwndwnd );
//hide console, not using to see if icon is null
//ShowWindow( hwndConsole, 0 );
//message loop
while(GetMessage( &msg, hwndwnd, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
这是我的源代码。 问题是否与我的资源有任何关系,这是我开始想到的。 当使用转基因器时,它就投放了一切可能的大小。 希望这一帮助,并感谢耐心。