Tk Source Code

Attachment Details
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.
Overview

Artifact ID: 15387088f87cbadac6319079a85ba9c6a5d6fa56
Ticket: 1032982fffffffffffffffffffffffffffffffff
Date: 2004-09-23 04:47:48
User: mdejong
Artifact Attached: e3b0006406333dc29c37f6c8963eeff6c2317daa
Filename:full_screen.c
Description:Example code to create fullscreen Win32 app
Content Appended
#include <windows.h>

static char g_szClassName[] = "MyWindowClass";
static HINSTANCE g_hInst = NULL;
static LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam);


int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
   LPSTR lpCmdLine, int nCmdShow)
{
   WNDCLASSEX WndClass;
   HWND hwnd;
   MSG Msg;

   g_hInst = hInstance;

   WndClass.cbSize        = sizeof(WNDCLASSEX);
   WndClass.style         = NULL;
   WndClass.lpfnWndProc   = WndProc;
   WndClass.cbClsExtra    = 0;
   WndClass.cbWndExtra    = 0;
   WndClass.hInstance     = g_hInst;
   WndClass.hIcon         = LoadIcon(NULL, IDI_APPLICATION);
   WndClass.hCursor       = LoadCursor(NULL, IDC_ARROW);
   WndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
   WndClass.lpszMenuName  = NULL;
   WndClass.lpszClassName = g_szClassName;
   WndClass.hIconSm       = LoadIcon(NULL, IDI_APPLICATION);

   if(!RegisterClassEx(&WndClass))
   {
      MessageBox(0, "Window Registration Failed!", "Error!",
         MB_ICONEXCLAMATION | MB_OK | MB_SYSTEMMODAL);
      return 0;
   }

   hwnd = CreateWindowEx(
      WS_EX_APPWINDOW /* Forces addition of start menu item for popup (works) */
      /*WS_EX_CLIENTEDGE*/ /* Draws a border around the edge of the popup (works) */
      /*WS_EX_TOOLWINDOW*/ /* Draws without over stat
      /*WS_EX_TOPMOST*/ /* Puts window on top, does not work */
      ,
      g_szClassName,
      "My Title",
      /*WS_OVERLAPPEDWINDOW*/ /* Regular window type */
      /*WS_POPUP*/ /* Not a "regular" window (works) */
      (WS_POPUP|WS_CLIPCHILDREN|CS_DBLCLKS) /* Tk like */
      ,
      0, 0,
      1024, 768,
      NULL, NULL, g_hInst, NULL);

   if(hwnd == NULL)
   {
      MessageBox(0, "Window Creation Failed!", "Error!",
         MB_ICONEXCLAMATION | MB_OK | MB_SYSTEMMODAL);
      return 0;
   }

   ShowWindow(hwnd, nCmdShow);
   UpdateWindow(hwnd);

   while(GetMessage(&Msg, NULL, 0, 0))
   {
      TranslateMessage(&Msg);
      DispatchMessage(&Msg);
   }
   return Msg.wParam;
}

LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
   switch(Message)
   {
      case WM_CLOSE:
         DestroyWindow(hwnd);
      break;
      case WM_DESTROY:
         PostQuitMessage(0);
      break;
      default:
         return DefWindowProc(hwnd, Message, wParam, lParam);
   }
   return 0;
}