本文整理汇总了C++中LoadIcon函数的典型用法代码示例。如果您正苦于以下问题:C++ LoadIcon函数的具体用法?C++ LoadIcon怎么用?C++ LoadIcon使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了LoadIcon函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CC_BREAK_IF
bool CCEGLView::Create(LPCTSTR pTitle, int w, int h)
{
bool bRet = false;
do
{
CC_BREAK_IF(m_hWnd);
HINSTANCE hInstance = GetModuleHandle( NULL );
WNDCLASS wc; // Windows Class Structure
// Redraw On Size, And Own DC For Window.
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
wc.lpfnWndProc = _WindowProc; // WndProc Handles Messages
wc.cbClsExtra = 0; // No Extra Window Data
wc.cbWndExtra = 0; // No Extra Window Data
wc.hInstance = hInstance; // Set The Instance
wc.hIcon = LoadIcon( NULL, IDI_WINLOGO ); // Load The Default Icon
wc.hCursor = LoadCursor( NULL, IDC_ARROW ); // Load The Arrow Pointer
wc.hbrBackground = NULL; // No Background Required For GL
wc.lpszMenuName = NULL; // We Don't Want A Menu
wc.lpszClassName = kWindowClassName; // Set The Class Name
CC_BREAK_IF(! RegisterClass(&wc) && 1410 != GetLastError());
// center window position
RECT rcDesktop;
GetWindowRect(GetDesktopWindow(), &rcDesktop);
// create window
m_hWnd = CreateWindowEx(
WS_EX_APPWINDOW | WS_EX_WINDOWEDGE, // Extended Style For The Window
kWindowClassName, // Class Name
pTitle, // Window Title
WS_CAPTION | WS_POPUPWINDOW | WS_MINIMIZEBOX, // Defined Window Style
0, 0, // Window Position
0, // Window Width
0, // Window Height
NULL, // No Parent Window
NULL, // No Menu
hInstance, // Instance
NULL );
CC_BREAK_IF(! m_hWnd);
m_eInitOrientation = CCDirector::sharedDirector()->getDeviceOrientation();
m_bOrientationInitVertical = (CCDeviceOrientationPortrait == m_eInitOrientation
|| kCCDeviceOrientationPortraitUpsideDown == m_eInitOrientation) ? true : false;
m_tSizeInPoints.cx = w;
m_tSizeInPoints.cy = h;
resize(w, h);
// init egl
m_pEGL = CCEGL::create(this);
if (! m_pEGL)
{
DestroyWindow(m_hWnd);
m_hWnd = NULL;
break;
}
s_pMainWindow = this;
bRet = true;
} while (0);
return bRet;
}
示例2: CommonInit
//.........这里部分代码省略.........
state->windows =
(SDL_Window **) SDL_malloc(state->num_windows *
sizeof(*state->windows));
if (!state->windows) {
fprintf(stderr, "Out of memory!\n");
return SDL_FALSE;
}
for (i = 0; i < state->num_windows; ++i) {
char title[1024];
if (state->num_windows > 1) {
SDL_snprintf(title, SDL_arraysize(title), "%s %d",
state->window_title, i + 1);
} else {
SDL_strlcpy(title, state->window_title, SDL_arraysize(title));
}
state->windows[i] =
SDL_CreateWindow(title, state->window_x, state->window_y,
state->window_w, state->window_h,
state->window_flags);
if (!state->windows[i]) {
fprintf(stderr, "Couldn't create window: %s\n",
SDL_GetError());
return SDL_FALSE;
}
if (SDL_SetWindowDisplayMode(state->windows[i], &fullscreen_mode) < 0) {
fprintf(stderr, "Can't set up fullscreen display mode: %s\n",
SDL_GetError());
return SDL_FALSE;
}
if (state->window_icon) {
SDL_Surface *icon = LoadIcon(state->window_icon);
if (icon) {
SDL_SetWindowIcon(state->windows[i], icon);
SDL_FreeSurface(icon);
}
}
SDL_ShowWindow(state->windows[i]);
if (!state->skip_renderer
&& (state->renderdriver
|| !(state->window_flags & SDL_WINDOW_OPENGL))) {
m = -1;
if (state->renderdriver) {
SDL_RendererInfo info;
n = SDL_GetNumRenderDrivers();
for (j = 0; j < n; ++j) {
SDL_GetRenderDriverInfo(j, &info);
if (SDL_strcasecmp(info.name, state->renderdriver) ==
0) {
m = j;
break;
}
}
if (m == n) {
fprintf(stderr,
"Couldn't find render driver named %s",
state->renderdriver);
return SDL_FALSE;
}
}
if (SDL_CreateRenderer
(state->windows[i], m, state->render_flags) < 0) {
示例3: WinMain
int WINAPI WinMain( HINSTANCE hinstance,
HINSTANCE hprevinstance,
LPSTR lpcmdline,
int ncmdshow)
{
WNDCLASSEX winclass; // this will hold the class we create
HWND hwnd; // generic window handle
MSG msg; // generic message
HDC hdc; // graphics device context
// first fill in the window class stucture
winclass.cbSize = sizeof(WNDCLASSEX);
winclass.style = CS_DBLCLKS | CS_OWNDC |
CS_HREDRAW | CS_VREDRAW;
winclass.lpfnWndProc = WindowProc;
winclass.cbClsExtra = 0;
winclass.cbWndExtra = 0;
winclass.hInstance = hinstance;
winclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
winclass.hCursor = LoadCursor(NULL, IDC_ARROW);
winclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
winclass.lpszMenuName = NULL;
winclass.lpszClassName = WINDOW_CLASS_NAME;
winclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
// save hinstance in global
hinstance_app = hinstance;
// register the window class
if (!RegisterClassEx(&winclass))
return(0);
// create the window
if (!(hwnd = CreateWindowEx(NULL, // extended style
WINDOW_CLASS_NAME, // class
"DirectDraw 24-Bit Bitmap Loading", // title
WS_POPUP | WS_VISIBLE,
0,0, // initial x,y
SCREEN_WIDTH,SCREEN_HEIGHT, // initial width, height
NULL, // handle to parent
NULL, // handle to menu
hinstance,// instance of this application
NULL))) // extra creation parms
return(0);
// save main window handle
main_window_handle = hwnd;
// initialize game here
Game_Init();
// enter main event loop
while(TRUE)
{
// test if there is a message in queue, if so get it
if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))
{
// test if this is a quit
if (msg.message == WM_QUIT)
break;
// translate any accelerator keys
TranslateMessage(&msg);
// send the message to the window proc
DispatchMessage(&msg);
} // end if
// main game processing goes here
Game_Main();
} // end while
// closedown game here
Game_Shutdown();
// return to Windows like this
return(msg.wParam);
} // end WinMain
示例4: FilterDialogProc
INT_PTR CALLBACK FilterDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
{
switch (Msg)
{
case WM_INITDIALOG:
{
CenterWindow(hDlg);
hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MAMEUI_ICON));
SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
hBrush = CreateSolidBrush(RGB(240, 240, 240));
DisableVisualStylesFilters(hDlg);
LPTREEFOLDER folder = GetCurrentFolder();
LPTREEFOLDER lpParent = NULL;
LPCFILTER_ITEM g_lpFilterList = GetFilterList();
dwFilters = 0;
if (folder != NULL)
{
char tmp[80];
win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_EDIT), g_FilterText.c_str());
Edit_SetSel(GetDlgItem(hDlg, IDC_FILTER_EDIT), 0, -1);
// Mask out non filter flags
dwFilters = folder->m_dwFlags & F_MASK;
// Display current folder name in dialog titlebar
snprintf(tmp, WINUI_ARRAY_LENGTH(tmp), "Filters for %s folder", folder->m_lpTitle);
win_set_window_text_utf8(hDlg, tmp);
if (GetFilterInherit())
{
lpParent = GetFolder(folder->m_nParent);
bool bShowExplanation = false;
if (lpParent)
{
std::string strText;
/* Check the Parent Filters and inherit them on child,
* No need to promote all games to parent folder, works as is */
dwpFilters = lpParent->m_dwFlags & F_MASK;
/*Check all possible Filters if inherited solely from parent, e.g. not being set explicitly on our folder*/
if ((dwpFilters & F_CLONES) && !(dwFilters & F_CLONES))
{
/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_CLONES));
strText.append(" (*)");
win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_CLONES), strText.c_str());
bShowExplanation = true;
}
if ((dwpFilters & F_NONWORKING) && !(dwFilters & F_NONWORKING))
{
/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_NONWORKING));
strText.append(" (*)");
win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_NONWORKING), strText.c_str());
bShowExplanation = true;
}
if ((dwpFilters & F_UNAVAILABLE) && !(dwFilters & F_UNAVAILABLE))
{
/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_UNAVAILABLE));
strText.append(" (*)");
win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_UNAVAILABLE), strText.c_str());
bShowExplanation = true;
}
if ((dwpFilters & F_VECTOR) && !(dwFilters & F_VECTOR))
{
/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_VECTOR));
strText.append(" (*)");
win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_VECTOR), strText.c_str());
bShowExplanation = true;
}
if ((dwpFilters & F_RASTER) && !(dwFilters & F_RASTER))
{
/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_RASTER));
strText.append(" (*)");
win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_RASTER), strText.c_str());
bShowExplanation = true;
}
if ((dwpFilters & F_ORIGINALS) && !(dwFilters & F_ORIGINALS))
{
/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_ORIGINALS));
strText.append(" (*)");
win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_ORIGINALS), strText.c_str());
bShowExplanation = true;
}
if ((dwpFilters & F_WORKING) && !(dwFilters & F_WORKING))
{
/*Add a Specifier to the Checkbox to show it was inherited from the parent*/
strText = win_get_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_WORKING));
strText.append(" (*)");
win_set_window_text_utf8(GetDlgItem(hDlg, IDC_FILTER_WORKING), strText.c_str());
//.........这里部分代码省略.........
示例5: AddCustomFileDialogProc
INT_PTR CALLBACK AddCustomFileDialogProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
{
switch (Msg)
{
case WM_INITDIALOG:
{
CenterWindow(hDlg);
hIcon = LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_MAMEUI_ICON));
SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
hBrush = CreateSolidBrush(RGB(240, 240, 240));
if (IsWindowsSevenOrHigher())
SendMessage(GetDlgItem(hDlg, IDC_CUSTOM_TREE), TVM_SETEXTENDEDSTYLE, TVS_EX_DOUBLEBUFFER, TVS_EX_DOUBLEBUFFER);
SetWindowTheme(GetDlgItem(hDlg, IDC_CUSTOM_TREE), L"Explorer", NULL);
TREEFOLDER **folders;
int num_folders = 0;
TVINSERTSTRUCT tvis;
TVITEM tvi;
bool first_entry = true;
HIMAGELIST treeview_icons = GetTreeViewIconList();
// current game passed in using DialogBoxParam()
driver_index = lParam;
(void)TreeView_SetImageList(GetDlgItem(hDlg, IDC_CUSTOM_TREE), treeview_icons, LVSIL_NORMAL);
GetFolders(&folders, &num_folders);
// insert custom folders into our tree view
for (int i = 0; i < num_folders; i++)
{
if (folders[i]->m_dwFlags & F_CUSTOM)
{
HTREEITEM hti;
if (folders[i]->m_nParent == -1)
{
memset(&tvi, 0, sizeof(TVITEM));
tvis.hParent = TVI_ROOT;
tvis.hInsertAfter = TVI_SORT;
tvi.mask = TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
tvi.pszText = folders[i]->m_lptTitle;
tvi.lParam = (LPARAM)folders[i];
tvi.iImage = GetTreeViewIconIndex(folders[i]->m_nIconId);
tvi.iSelectedImage = 0;
tvis.item = tvi;
hti = TreeView_InsertItem(GetDlgItem(hDlg, IDC_CUSTOM_TREE), &tvis);
/* look for children of this custom folder */
for (int jj = 0; jj < num_folders; jj++)
{
if (folders[jj]->m_nParent == i)
{
HTREEITEM hti_child;
tvis.hParent = hti;
tvis.hInsertAfter = TVI_SORT;
tvi.mask = TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
tvi.pszText = folders[jj]->m_lptTitle;
tvi.lParam = (LPARAM)folders[jj];
tvi.iImage = GetTreeViewIconIndex(folders[jj]->m_nIconId);
tvi.iSelectedImage = 0;
tvis.item = tvi;
hti_child = TreeView_InsertItem(GetDlgItem(hDlg, IDC_CUSTOM_TREE), &tvis);
if (folders[jj] == default_selection)
(void)TreeView_SelectItem(GetDlgItem(hDlg, IDC_CUSTOM_TREE), hti_child);
}
}
/*TreeView_Expand(GetDlgItem(hDlg,IDC_CUSTOM_TREE),hti,TVE_EXPAND);*/
if (first_entry || folders[i] == default_selection)
{
(void)TreeView_SelectItem(GetDlgItem(hDlg, IDC_CUSTOM_TREE),hti);
first_entry = false;
}
}
}
}
win_set_window_text_utf8(GetDlgItem(hDlg, IDC_CUSTOMFILE_GAME), GetDriverGameTitle(driver_index));
return true;
}
case WM_CTLCOLORDLG:
return (LRESULT) hBrush;
case WM_CTLCOLORSTATIC:
case WM_CTLCOLORBTN:
hDC = (HDC)wParam;
SetBkMode(hDC, TRANSPARENT);
SetTextColor(hDC, GetSysColor(COLOR_WINDOWTEXT));
return (LRESULT) hBrush;
case WM_COMMAND:
switch (GET_WM_COMMAND_ID(wParam, lParam))
{
case IDOK:
{
//.........这里部分代码省略.........
示例6: LoadIcon
void NetGseEx::DrawOfficeASE(HINSTANCE hinst, HWND hwnd, HDC hdc, ActorRequest* ActReq)
{
static BOOL Init = TRUE;
if (Init == TRUE) {
Init = FALSE;
IconHndl[1] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON1));
IconHndl[2] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON2));
IconHndl[3] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON3));
IconHndl[4] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON4));
IconHndl[5] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON5));
IconHndl[6] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON6));
IconHndl[7] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON7));
IconHndl[8] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON8));
IconHndl[9] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON9));
IconHndl[10] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON10));
IconHndl[11] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON11));
IconHndl[12] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON12));
IconHndl[13] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON13));
IconHndl[14] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON14));
IconHndl[15] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON15));
IconHndl[16] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON16));
IconHndl[17] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON17));
IconHndl[18] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON18));
IconHndl[19] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON19));
IconHndl[20] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON20));
IconHndl[21] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON21));
IconHndl[22] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON22));
IconHndl[23] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON23));
IconHndl[24] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON24));
IconHndl[25] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON25));
IconHndl[26] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON26));
IconHndl[27] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON27));
IconHndl[28] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON28));
IconHndl[29] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON29));
IconHndl[30] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON30));
IconHndl[31] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON31));
IconHndl[32] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON32));
IconHndl[33] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON33));
IconHndl[34] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON34));
IconHndl[35] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON35));
IconHndl[36] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON36));
IconHndl[37] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON37));
IconHndl[38] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON38));
IconHndl[39] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON39));
IconHndl[40] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON40));
IconHndl[41] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON41));
IconHndl[42] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON42));
IconHndl[43] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON43));
IconHndl[44] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON44));
IconHndl[45] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON45));
IconHndl[46] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON46));
IconHndl[47] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON47));
IconHndl[48] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON48));
IconHndl[50] = (HICON)LoadImage(hinst, MAKEINTRESOURCE(IDI_ICON50), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
IconHndl[51] = (HICON)LoadImage(hinst, MAKEINTRESOURCE(IDI_ICON51), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
IconHndl[52] = (HICON)LoadImage(hinst, MAKEINTRESOURCE(IDI_ICON52), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
IconHndl[53] = (HICON)LoadImage(hinst, MAKEINTRESOURCE(IDI_ICON53), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
IconHndl[54] = (HICON)LoadImage(hinst, MAKEINTRESOURCE(IDI_ICON54), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
IconHndl[55] = (HICON)LoadImage(hinst, MAKEINTRESOURCE(IDI_ICON55), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
IconHndl[56] = (HICON)LoadImage(hinst, MAKEINTRESOURCE(IDI_ICON56), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
IconHndl[60] = (HICON)LoadImage(hinst, MAKEINTRESOURCE(IDI_ICON60), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
IconHndl[61] = (HICON)LoadImage(hinst, MAKEINTRESOURCE(IDI_ICON61), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
IconHndl[62] = (HICON)LoadImage(hinst, MAKEINTRESOURCE(IDI_ICON62), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
IconHndl[71] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON71));
IconHndl[72] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON72));
IconHndl[73] = LoadIcon(hinst, MAKEINTRESOURCE(IDI_ICON73));
}
int r = ActReq->GetRequest();
int c = ActReq->GetActorId();
int bottom = ActReq->GetIntParam1();
int top = ActReq->GetIntParam2();
int right = ActReq->GetIntParam3();
int left = ActReq->GetIntParam4();
TCHAR* NameBuf = ActReq->GetStringParam1();
StkFont* Fon = StkFont::GetInstance();
if (r < 0) {
RECT rt;
HBRUSH b1 = CreateSolidBrush(RGB(255, 255, 255));
SelectObject(hdc, b1);
rt.right = right;
rt.left = left;
rt.top = top;
rt.bottom = bottom;
FillRect(hdc, &rt, b1);
DeleteObject(b1);
r *= -1;
}
int SizeW = right - left;
int SizeH = bottom - top;
DrawIconEx(hdc, left, top, IconHndl[r], SizeW, SizeH, NULL, NULL, DI_NORMAL);
Fon->ArialFontSmallTextOut(hdc, left + SizeW / 2, bottom + 5, NameBuf, RGB(255, 255, 255), TRUE);
}
示例7: CreateGLWindow
BOOL CreateGLWindow(char* title, int width, int height, int bits, bool fullscreenflag)
{
GLuint PixelFormat; // Holds The Results After Searching For A Match
WNDCLASS wc; // Windows Class Structure
DWORD dwExStyle; // Window Extended Style
DWORD dwStyle; // Window Style
RECT WindowRect; // Grabs Rectangle Upper Left / Lower Right Values
WindowRect.left=(long)0; // Set Left Value To 0
WindowRect.right=(long)width; // Set Right Value To Requested Width
WindowRect.top=(long)0; // Set Top Value To 0
WindowRect.bottom=(long)height; // Set Bottom Value To Requested Height
fullscreen=fullscreenflag; // Set The Global Fullscreen Flag
hInstance = GetModuleHandle(NULL); // Grab An Instance For Our Window
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; // Redraw On Size, And Own DC For Window.
wc.lpfnWndProc = (WNDPROC) WndProc; // WndProc Handles Messages
wc.cbClsExtra = 0; // No Extra Window Data
wc.cbWndExtra = 0; // No Extra Window Data
wc.hInstance = hInstance; // Set The Instance
wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); // Load The Default Icon
wc.hCursor = LoadCursor(NULL, IDC_ARROW); // Load The Arrow Pointer
wc.hbrBackground = NULL; // No Background Required For GL
wc.lpszMenuName = NULL; // We Don't Want A Menu
wc.lpszClassName = "OpenGL"; // Set The Class Name
if (!RegisterClass(&wc)) // Attempt To Register The Window Class
{
MessageBox(NULL,"Failed To Register The Window Class.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE; // Return FALSE
}
if (fullscreen) // Attempt Fullscreen Mode?
{
DEVMODE dmScreenSettings; // Device Mode
memset(&dmScreenSettings,0,sizeof(dmScreenSettings)); // Makes Sure Memory's Cleared
dmScreenSettings.dmSize=sizeof(dmScreenSettings); // Size Of The Devmode Structure
dmScreenSettings.dmPelsWidth = width; // Selected Screen Width
dmScreenSettings.dmPelsHeight = height; // Selected Screen Height
dmScreenSettings.dmBitsPerPel = bits; // Selected Bits Per Pixel
dmScreenSettings.dmFields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;
// Try To Set Selected Mode And Get Results. NOTE: CDS_FULLSCREEN Gets Rid Of Start Bar.
if (ChangeDisplaySettings(&dmScreenSettings,CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL)
{
// If The Mode Fails, Offer Two Options. Quit Or Use Windowed Mode.
if (MessageBox(NULL,"The Requested Fullscreen Mode Is Not Supported By\nYour Video Card. Use Windowed Mode Instead?","NeHe GL",MB_YESNO|MB_ICONEXCLAMATION)==IDYES)
{
fullscreen=FALSE; // Windowed Mode Selected. Fullscreen = FALSE
}
else
{
// Pop Up A Message Box Letting User Know The Program Is Closing.
MessageBox(NULL,"Program Will Now Close.","ERROR",MB_OK|MB_ICONSTOP);
return FALSE; // Return FALSE
}
}
}
if (fullscreen) // Are We Still In Fullscreen Mode?
{
dwExStyle=WS_EX_APPWINDOW; // Window Extended Style
dwStyle=WS_POPUP; // Windows Style
ShowCursor(FALSE); // Hide Mouse Pointer
}
else
{
dwExStyle=WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; // Window Extended Style
dwStyle=WS_OVERLAPPEDWINDOW; // Windows Style
}
AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, dwExStyle); // Adjust Window To True Requested Size
// Create The Window
if (!(hWnd=CreateWindowEx( dwExStyle, // Extended Style For The Window
"OpenGL", // Class Name
title, // Window Title
dwStyle | // Defined Window Style
WS_CLIPSIBLINGS | // Required Window Style
WS_CLIPCHILDREN, // Required Window Style
0, 0, // Window Position
WindowRect.right-WindowRect.left, // Calculate Window Width
WindowRect.bottom-WindowRect.top, // Calculate Window Height
NULL, // No Parent Window
NULL, // No Menu
hInstance, // Instance
NULL))) // Dont Pass Anything To WM_CREATE
{
KillGLWindow(); // Reset The Display
MessageBox(NULL,"Window Creation Error.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE; // Return FALSE
}
static PIXELFORMATDESCRIPTOR pfd= // pfd Tells Windows How We Want Things To Be
{
sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
1, // Version Number
PFD_DRAW_TO_WINDOW | // Format Must Support Window
PFD_SUPPORT_OPENGL | // Format Must Support OpenGL
PFD_DOUBLEBUFFER, // Must Support Double Buffering
//.........这里部分代码省略.........
示例8: DialogProcUninstall
static BOOL CALLBACK DialogProcUninstall(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
static HICON hIcon;
int x;
TCHAR tmpbuf[MAX_PATH];
if (uMsg == WM_DESTROY && hIcon) { DeleteObject(hIcon); hIcon=0; }
if (uMsg == WM_INITDIALOG || uMsg == WM_USER+1)
{
struct
{
LPTSTR id;
WNDPROC proc;
LPTSTR s;
}
windows[2]=
{
{MAKEINTRESOURCE(IDD_UNINST),UninstProc,""},
{MAKEINTRESOURCE(IDD_INSTFILES),InstProc,""},
};
int messages[2] = { JAVAWS_MESSAGE_CONFIRM, JAVAWS_MESSAGE_UNINSTFILES };
for (x=0; x<2; x++) {
GETRESOURCE(tmpbuf, messages[x]);
windows[x].s = (LPTSTR)GlobalAlloc(GMEM_FIXED, (_tcslen(tmpbuf) + 1) * sizeof(TCHAR));
_tcscpy(windows[x].s, tmpbuf);
}
if (uMsg == WM_INITDIALOG)
{
g_hwnd=hwndDlg;
hIcon=LoadIcon(g_hInstance,MAKEINTRESOURCE(IDI_ICON2));
SetClassLong(hwndDlg,GCL_HICON,(long)hIcon);
EnableWindow(GetDlgItem(hwndDlg,IDC_BACK),0);
}
if (m_curwnd) DestroyWindow(m_curwnd);
if (m_page < 0 || m_page > 1)
{
EndDialog(hwndDlg,0);
}
else
{
INT32 args[] = { (INT32)m_uninstheader->name, (INT32)windows[m_page].s };
m_curwnd=CreateDialog(g_hInstance,windows[m_page].id,hwndDlg,windows[m_page].proc);
GETRESOURCE2(tmpbuf, JAVAWS_MESSAGE_UNINSTALL2, args);
SetWindowText(hwndDlg,tmpbuf);
}
if (m_curwnd)
{
RECT r;
GetWindowRect(GetDlgItem(hwndDlg,IDC_CHILDRECT),&r);
ScreenToClient(hwndDlg,(LPPOINT)&r);
SetWindowPos(m_curwnd,0,r.left,r.top,0,0,SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOZORDER);
ShowWindow(m_curwnd,SW_SHOWNA);
}
}
if (uMsg == WM_COMMAND)
{
int id=LOWORD(wParam);
if (id == IDOK && m_curwnd)
{
m_page++;
SendMessage(hwndDlg,WM_USER+1,0,0);
}
if (id == IDCANCEL)
{
EndDialog(hwndDlg,2);
}
}
return 0;
}
示例9: Sys_CreateConsole
/*
** Sys_CreateConsole
*/
void Sys_CreateConsole( void )
{
HDC hDC;
WNDCLASS wc;
RECT rect;
const char *DEDCLASS = "Q3 WinConsole";
int nHeight;
int swidth, sheight;
int DEDSTYLE = WS_POPUPWINDOW | WS_CAPTION | WS_MINIMIZEBOX;
memset( &wc, 0, sizeof( wc ) );
wc.style = 0;
wc.lpfnWndProc = (WNDPROC) ConWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = g_wv.hInstance;
wc.hIcon = LoadIcon( g_wv.hInstance, MAKEINTRESOURCE(IDI_ICON1));
wc.hCursor = LoadCursor (NULL,IDC_ARROW);
wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
wc.lpszMenuName = 0;
wc.lpszClassName = DEDCLASS;
if ( !RegisterClass (&wc) )
return;
rect.left = 0;
rect.right = 540;
rect.top = 0;
rect.bottom = 450;
AdjustWindowRect( &rect, DEDSTYLE, FALSE );
hDC = GetDC( GetDesktopWindow() );
swidth = GetDeviceCaps( hDC, HORZRES );
sheight = GetDeviceCaps( hDC, VERTRES );
ReleaseDC( GetDesktopWindow(), hDC );
s_wcd.windowWidth = rect.right - rect.left + 1;
s_wcd.windowHeight = rect.bottom - rect.top + 1;
s_wcd.hWnd = CreateWindowEx( 0,
DEDCLASS,
CONSOLE_WINDOW_TITLE,
DEDSTYLE,
( swidth - 600 ) / 2, ( sheight - 450 ) / 2 , rect.right - rect.left + 1, rect.bottom - rect.top + 1,
NULL,
NULL,
g_wv.hInstance,
NULL );
if ( s_wcd.hWnd == NULL )
{
return;
}
//
// create fonts
//
hDC = GetDC( s_wcd.hWnd );
nHeight = -MulDiv( 8, GetDeviceCaps( hDC, LOGPIXELSY), 72);
s_wcd.hfBufferFont = CreateFont( nHeight,
0,
0,
0,
FW_LIGHT,
0,
0,
0,
DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,
FF_MODERN | FIXED_PITCH,
"Courier New" );
ReleaseDC( s_wcd.hWnd, hDC );
//
// create the input line
//
s_wcd.hwndInputLine = CreateWindow( "edit", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER |
ES_LEFT | ES_AUTOHSCROLL,
6, 400, 528, 20,
s_wcd.hWnd,
( HMENU ) INPUT_ID, // child window ID
g_wv.hInstance, NULL );
//
// create the buttons
//
s_wcd.hwndButtonCopy = CreateWindow( "button", NULL, BS_PUSHBUTTON | WS_VISIBLE | WS_CHILD | BS_DEFPUSHBUTTON,
5, 425, 72, 24,
s_wcd.hWnd,
( HMENU ) COPY_ID, // child window ID
g_wv.hInstance, NULL );
SendMessage( s_wcd.hwndButtonCopy, WM_SETTEXT, 0, ( LPARAM ) "copy" );
//.........这里部分代码省略.........
示例10: _tWinMain
int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPTSTR lpCmdLine, _In_ int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
MSG msg;
HACCEL hAccelTable;
WNDCLASSEX wcex;
#ifdef _DEBUG
INIT_CRT_DEBUG_REPORT();
//_CrtSetBreakAlloc(290);
#endif
wcex.cbSize = sizeof(WNDCLASSEX);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = MainWnd::WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wcex.lpszMenuName = MAKEINTRESOURCE(IDC_APIGATE);
wcex.lpszClassName = MainWnd::szClassName;
wcex.hIconSm = wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APIGATE));
if (!RegisterClassEx(&wcex))
{
return -1;
}
g_hInstance = hInstance;
//if (!AfxWinInit(hInstance, hPrevInstance, lpCmdLine, nCmdShow))
// TRACE("AfxWinInit failed.\n");
s_hRichEdit = LoadLibrary(_T("RICHED20.DLL"));
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
// if (!AfxInitRichEdit2())
// TRACE("AfxInitRichEdit failed.\n");
g_api = new ApiMan();
g_svr = new SvrMan();
if (!g_mainwnd.Create(nCmdShow))
{
goto _finish;
}
hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDC_APIGATE));
while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
_finish:
g_mainwnd.Destroy();
delete g_svr;
delete g_api;
FreeLibrary(s_hRichEdit);
UnregisterClass(MainWnd::szClassName, hInstance);
return 0;// (int)msg.wParam;
}
示例11: DialogProc
static BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
static HICON hIcon;
TCHAR tmpbuf[MAX_PATH];
if (uMsg == WM_DESTROY && hIcon) { DeleteObject(hIcon); hIcon=0; }
if (uMsg == WM_INITDIALOG || uMsg == WM_USER+1)
{
int backenabled=0,iscp=1,islp=1, x;
struct
{
LPTSTR id;
WNDPROC proc;
LPTSTR s;
}
windows[4]=
{
{MAKEINTRESOURCE(IDD_LICENSE),LicenseProc,""},
{MAKEINTRESOURCE(IDD_SELCOM),LicenseProc,""},
{MAKEINTRESOURCE(IDD_DIR),DirProc,""},
{MAKEINTRESOURCE(IDD_INSTFILES),InstProc,""},
};
int messages[4] = { JAVAWS_MESSAGE_LICENSE, JAVAWS_MESSAGE_INSTOPT,
JAVAWS_MESSAGE_INSTDIR, JAVAWS_MESSAGE_INSTFILES };
for( x=0; x<4; x++) {
GETRESOURCE(tmpbuf, messages[x]);
windows[x].s = (LPTSTR)malloc((_tcslen(tmpbuf) + 1) * sizeof(TCHAR));
_tcscpy(windows[x].s, tmpbuf);
}
if (uMsg == WM_INITDIALOG)
{
g_hwnd=hwndDlg;
hIcon=LoadIcon(g_hInstance,MAKEINTRESOURCE(IDI_ICON2));
SetClassLong(hwndDlg,GCL_HICON,(long)hIcon);
}
if (m_curwnd) DestroyWindow(m_curwnd);
if (!m_header->licensetext[0] || m_header->licensedata_offset==-1) islp=0;
if (m_page==0 && !islp) m_page++;
if (m_page==1 && autoinstall == 2) {
/* skip the rest of the dialog because it's an autoinstall */
g_hwnd = NULL;
EndDialog(hwndDlg,3);
}
if (m_header->num_sections < 2) iscp=0;
{
int id=LOWORD(wParam);
if (uMsg==(WM_USER+1) && id==IDC_BACK) {
if (m_page==1 && !iscp) m_page--;
} else {
if (m_page==1 && !iscp) m_page++;
}
}
if (m_page==1&&islp) backenabled=1;
if (m_page==2&&(islp||iscp)) backenabled=1;
if (m_page < 0 || m_page > 3)
{
EndDialog(hwndDlg,0);
}
else
{
HWND hwnd;
GETRESOURCE(tmpbuf,JAVAWS_BACK);
SetDlgItemText(hwndDlg,IDC_BACK,tmpbuf);
if (m_page==0) {
GETRESOURCE(tmpbuf,JAVAWS_DECLINE);
SetDlgItemText(hwndDlg,IDCANCEL,tmpbuf);
GETRESOURCE(tmpbuf,JAVAWS_ACCEPT);
SetDlgItemText(hwndDlg,IDOK,tmpbuf);
hwnd=GetDlgItem(hwndDlg, IDC_BACK);
ShowWindow(hwnd,SW_HIDE);
} else {
GETRESOURCE(tmpbuf,JAVAWS_CANCEL);
SetDlgItemText(hwndDlg,IDCANCEL,tmpbuf);
GETRESOURCE(tmpbuf,JAVAWS_NEXT);
SetDlgItemText(hwndDlg,IDOK,tmpbuf);
hwnd=GetDlgItem(hwndDlg, IDC_BACK);
ShowWindow(hwnd,SW_SHOWNA);
}
{
INT32 args[] = { (INT32)m_header->name, (INT32)windows[m_page].s };
m_curwnd=CreateDialog(g_hInstance,windows[m_page].id,hwndDlg,windows[m_page].proc);
GETRESOURCE2(tmpbuf, JAVAWS_MESSAGE_SETUP2, args);
SetWindowText(hwndDlg,tmpbuf);
}
}
if (m_curwnd)
{
RECT r;
GetWindowRect(GetDlgItem(hwndDlg,IDC_CHILDRECT),&r);
ScreenToClient(hwndDlg,(LPPOINT)&r);
SetWindowPos(m_curwnd,0,r.left,r.top,0,0,SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOZORDER);
ShowWindow(m_curwnd,SW_SHOWNA);
EnableWindow(GetDlgItem(hwndDlg,IDC_BACK),backenabled);
}
}
if (uMsg == WM_COMMAND)
{
int id=LOWORD(wParam);
//.........这里部分代码省略.........
示例12: _tWinMain
//==============================================================================
// エントリーポイント
//==============================================================================
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
HWND hwnd;
MSG msg;
WNDCLASS winc;
winc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
winc.lpfnWndProc = WndProc; // ウィンドウプロシージャ
winc.cbClsExtra = 0;
winc.cbWndExtra = 0;
winc.hInstance = hInstance;
winc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
winc.hCursor = LoadCursor(NULL, IDC_ARROW);
winc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
winc.lpszMenuName = NULL;
winc.lpszClassName = CLASS_NAME;
// ウィンドウクラス登録
if(RegisterClass(&winc) == false)
{
return 1;
}
// ウィンドウ作成
hwnd = CreateWindow(
CLASS_NAME,
CLASS_NAME,
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
0, 0,
SCREEN_WIDTH + GetSystemMetrics(SM_CXFRAME) * 2,
SCREEN_HEIGHT + GetSystemMetrics(SM_CYFRAME) * 2 + GetSystemMetrics(SM_CYCAPTION),
NULL,
NULL,
hInstance,
NULL);
if(hwnd == NULL)
{
return 1;
}
// Vulkan初期化
if(initVulkan(hInstance, hwnd) == false)
{
return 1;
}
// ウィンドウ表示
ShowWindow(hwnd, nCmdShow);
FPSCounter fpsCounter; // FPSカウンター
// メッセージループ
do {
fpsCounter.beginCount();
if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
// メイン
Render();
}
fpsCounter.endCount();
std::string windowTitle = std::string(APPLICATION_NAME) + " - " + std::to_string(fpsCounter.getLastFPS()) + " FPS";
SetWindowText(hwnd, windowTitle.c_str());
} while(msg.message != WM_QUIT);
// Vulkan破棄
destroyVulkan();
// 登録したクラスを解除
UnregisterClass(CLASS_NAME, hInstance);
return 0;
}
示例13: createMainWin
/** make the main window **/
HWND createMainWin(HINSTANCE hThisInstance, int sizeX, int sizeY){
/** declare a class name. Why? Because. **/
TCHAR szClassName[ ] = _T("Student Project");
/** declare the main window handle **/
HWND hwnd = NULL;
/** declare data structure object variable for the window class **/
WNDCLASSEX wincl;
/** initialize the window structure **/
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure; // This function is called by windows
wincl.style = CS_DBLCLKS; // Catch double-clicks
wincl.cbSize = sizeof (WNDCLASSEX);
/** use default icon and mouse-pointer **/
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
/** no menu **/
wincl.lpszMenuName = NULL;
/** no extra bytes after the window class structure
or the window instance */
wincl.cbClsExtra = 0;
wincl.cbWndExtra = 0;
/** add a custom background color */
wincl.hbrBackground = CreateSolidBrush(RGB(255, 255, 255));
/** Register the window class, if it fails quit the program */
if(!RegisterClassEx(&wincl))
return 0;
/** the class is registered,
let's create the programs main window */
hwnd = CreateWindowEx(
0, // extended possibilities for variation
szClassName, // Class name
_T(" WinBreakoutC++ "), // Title Text
WS_OVERLAPPEDWINDOW, // default window style
CW_USEDEFAULT, // windows decides the position
CW_USEDEFAULT, // where the window ends up on the screen
sizeX, // the window width
sizeY, // and height in pixels
HWND_DESKTOP, // the window is a child-window to desktop
NULL, // no menu
hThisInstance, // the program instance handle
NULL // no window creation data
);
/** if window creation successful return the main window handle
any work in the window will need this handle **/
if(hwnd)
return hwnd;
/** if we get this far we have failed to create
a window for our program, returning 0 will
cause a message to the user and then quit the process. **/
return 0;
}
示例14: WinMain
int APIENTRY WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR command_line, int nCmdShow)
{
MSG msg;
WNDCLASS wndclass;
HANDLE hAccel;
# ifdef THREAD_LOCAL_ALLOC
GC_INIT(); /* Required if GC is built with THREAD_LOCAL_ALLOC */
/* Always safe, but this is used as a GC test. */
# endif
if (!hPrevInstance)
{
wndclass.style = CS_HREDRAW | CS_VREDRAW;
wndclass.lpfnWndProc = WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = DLGWINDOWEXTRA;
wndclass.hInstance = hInstance;
wndclass.hIcon = LoadIcon (hInstance, szAppName);
wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);
wndclass.hbrBackground = GetStockObject(WHITE_BRUSH);
wndclass.lpszMenuName = TEXT("DE");
wndclass.lpszClassName = szAppName;
if (RegisterClass (&wndclass) == 0) {
char buf[50];
sprintf(buf, "RegisterClass: error code: 0x%X",
(unsigned)GetLastError());
de_error(buf);
return(0);
}
}
/* Empirically, the command line does not include the command name ...
if (command_line != 0) {
while (isspace(*command_line)) command_line++;
while (*command_line != 0 && !isspace(*command_line)) command_line++;
while (isspace(*command_line)) command_line++;
} */
if (command_line == 0 || *command_line == 0) {
de_error("File name argument required");
return( 0 );
} else {
char *p = command_line;
while (*p != 0 && !isspace(*(unsigned char *)p))
p++;
arg_file_name = CORD_to_char_star(
CORD_substr(command_line, 0, p - command_line));
}
hwnd = CreateWindow (szAppName,
TEXT("Demonstration Editor"),
WS_OVERLAPPEDWINDOW | WS_CAPTION, /* Window style */
CW_USEDEFAULT, 0, /* default pos. */
CW_USEDEFAULT, 0, /* default width, height */
NULL, /* No parent */
NULL, /* Window class menu */
hInstance, NULL);
if (hwnd == NULL) {
char buf[50];
sprintf(buf, "CreateWindow: error code: 0x%X",
(unsigned)GetLastError());
de_error(buf);
return(0);
}
ShowWindow (hwnd, nCmdShow);
hAccel = LoadAccelerators( hInstance, szAppName );
while (GetMessage (&msg, NULL, 0, 0))
{
if( !TranslateAccelerator( hwnd, hAccel, &msg ) )
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
}
return msg.wParam;
}
示例15: WinMain
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow) {
char const * const className = "3DClass";
WNDCLASSEX
windowClass;
windowClass.cbSize = sizeof(WNDCLASSEX);
windowClass.style = CS_HREDRAW | CS_VREDRAW;
windowClass.lpfnWndProc = WindowProc;
windowClass.cbClsExtra = 0;
windowClass.cbWndExtra = 0;
windowClass.hInstance = hInstance;
windowClass.hIcon = LoadIcon (NULL, IDI_APPLICATION);
windowClass.hCursor = LoadCursor(NULL, IDC_ARROW);
windowClass.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);
windowClass.lpszMenuName = NULL;
windowClass.lpszClassName = className;
windowClass.hIconSm = LoadIcon(NULL, IDI_WINLOGO);
RegisterClassEx(&windowClass);
DWORD dwExStyle;
DWORD dwStyle;
dwStyle = // WS_CLIPCHILDREN |
// WS_CLIPSIBLINGS |
// WS_SIZEBOX |
// WS_CAPTION |
WS_SYSMENU | // show "x" in top right corner to close window.
WS_OVERLAPPED ;
dwExStyle = WS_EX_APPWINDOW | WS_EX_WINDOWEDGE;
RECT windowRect = {0, 0, windowWidth, windowHeight};
AdjustWindowRectEx(&windowRect, dwStyle, FALSE, dwExStyle);
HWND hwnd = CreateWindowEx(
dwExStyle,
className,
"TODO: App Name",
dwStyle,
0, 0, // x and y coords
windowRect.right - windowRect.left,
windowRect.bottom - windowRect.top, // width, height
NULL, // handle to parent
NULL, // handle to menu
hInstance, // application instance
NULL); // no xtra params
if (! hwnd) {
MessageBox(0, "Main window could not be created", "Error", 0);
return 0;
}
ShowWindow(hwnd, SW_SHOW);
UpdateWindow(hwnd);
MSG Msg;
while (GetMessage(&Msg, NULL, 0, 0) ) {
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}