示例#1
0
void Window::SetBkColor(COLORREF Col)
{
    HBRUSH Brush=CreateSolidBrush(Col);
#ifdef WIN32
    HBRUSH OldBrush=(HBRUSH) SetClassLong(hWnd,GCL_HBRBACKGROUND,(LONG) Brush);
#else
    HBRUSH OldBrush=SetClassWord(hWnd,GCW_HBRBACKGROUND,Brush);
#endif
    DeleteObject(OldBrush); // what if stock objcect ?
    InvalidateRect(hWnd,NULL,TRUE);
}
示例#2
0
void Window::SetIcon(int id)
{
    Icon=id;
    if (hWnd && Icon>=0)
    {
        HICON I=LoadIcon(App::hInstance,MAKEINTRESOURCE(id));
#ifdef WIN32
        ::SendMessage(hWnd,WM_SETICON,ICON_BIG,(LPARAM)I);
#else
        HICON OldIcon=(HICON) SetClassWord(hWnd,GCW_HICON, I);
        if (OldIcon) DestroyIcon(OldIcon);
#endif
    }
}
示例#3
0
int PASCAL 
WinMain(HANDLE hInstance, HANDLE hPrevInstance, LPSTR lpszCmdLine, int cmdShow)
{
	WNDCLASS wndclass;

	char modulename[MAXSTR];

	/* Initialize the list of open Windows devices */
	gdev_win_open_list = 0;

	/* copy the hInstance into a variable so it can be used */
	phInstance = hInstance;

        /* start up the text window */
	_ScreenSize.y = 50;
	_InitEasyWin();

	/* fix up the EasyWindows window provided by Borland */
	GetModuleFileName(hInstance, (LPSTR) modulename, MAXSTR);
	hwndeasy = FindWindow("BCEasyWin", modulename);
	SetWindowText(hwndeasy, szAppName);            /* change title */
	SetClassWord(hwndeasy, GCW_HICON, LoadIcon(hInstance, "texticon"));

	/* if this is the first Ghostscript then register the window class */
	/* for graphics */
	if (!hPrevInstance) {
		wndclass.style = CS_HREDRAW | CS_VREDRAW;
		wndclass.lpfnWndProc = WndProc;
		wndclass.cbClsExtra = 0;
		wndclass.cbWndExtra = 0;
		wndclass.hInstance = hInstance;
		wndclass.hIcon = LoadIcon(hInstance,"grpicon");
		wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
		wndclass.hbrBackground = GetStockObject(WHITE_BRUSH);
		wndclass.lpszMenuName = NULL;
		wndclass.lpszClassName = szAppName;
		RegisterClass(&wndclass);
	}

	(void) atexit(win_exit); /* setup exit handler */

	main(_argc, _argv, environ);

	/* never reached */
	win_exit(); 
	return 0;
}
示例#4
0
BOOL PEXPORT kpc_set_window_background(ATOMID idWindow, HWND hWnd, 
                                       float fRed, float fGreen, float fBlue)
{
    short sRed = 0, sGreen = 0, sBlue = 0;

    if (hWnd == (HWND) -1 || 
        hWnd == KpphWndTraceCB() || hWnd == KpphWndKALCB())
        return FALSE;

    check_and_set_color(&sRed, &fRed);
    check_and_set_color(&sGreen, &fGreen);
    check_and_set_color(&sBlue, &fBlue);

    if (KpsIsASessionWindow(hWnd))
    {
        LISTID idBack = KppMakeList(0);

        KppAppendElem(idBack, KappaMakeInt(sRed));
        KppAppendElem(idBack, KappaMakeInt(sGreen));
        KppAppendElem(idBack, KappaMakeInt(sBlue));
        KppSetSlotValue(idWindow, lpSNs->idTextBackColorSN, idBack, EXPLIST);
    }   
    else
    {
        HBRUSH hOldBrush = GetClassWord(hWnd, GCW_HBRBACKGROUND);
        short sOffset = KpsGetWindowOffset(hWnd);
        
        SetClassWord(hWnd, GCW_HBRBACKGROUND,
                     CreateSolidBrush(RGB(sRed, sGreen, sBlue)));

        if (sOffset == -1)
            return FALSE;
        if (!bWinBackground[sOffset])
            bWinBackground[sOffset] = 1;
        else if (hOldBrush)
            DeleteObject(hOldBrush);
    }    

    InvalidateRect(hWnd, NULL, TRUE);
    UpdateWindow(hWnd);

    return TRUE;
}
示例#5
0
ULONG FASTCALL WU32SetClassWord(PVDMFRAME pFrame)
{
    ULONG  ul, flag;
    HWND   hwnd;
    INT    iOffset;
    register PSETCLASSWORD16 parg16;

    GETARGPTR(pFrame, sizeof(SETCLASSWORD16), parg16);

    // Make sure Win32 didn't change offsets

#if (GCL_HBRBACKGROUND != (-10) || GCL_HCURSOR != (-12) || GCL_HICON != (-14) || GCL_CBWNDEXTRA != (-18) || GCL_CBCLSEXTRA != (-20) || GCL_STYLE != (-26))
#error Win16/Win32 GCW constants differ
#endif

    // Make sure the 16-bit app is requesting allowable offsets
    // (It's just assertion code, so it doesn't have to be pretty! -JTP)

    iOffset = INT32(parg16->f2);
    WOW32ASSERT(iOffset >= 0 ||
        iOffset == GCL_HBRBACKGROUND ||
        iOffset == GCL_HCURSOR ||
        iOffset == GCL_HICON ||
        iOffset == GCL_CBWNDEXTRA ||
        iOffset == GCL_CBCLSEXTRA ||
        iOffset == GCL_STYLE)

    hwnd = HWND32(parg16->f1);
    ul = WORD32(parg16->f3);

    switch(iOffset) {
        case GCL_HBRBACKGROUND:
            if (ul > COLOR_ENDCOLORS)
                ul = (LONG) HBRUSH32(ul);

            ul = SetClassLong(hwnd, iOffset, (LONG) ul);

            if (ul > COLOR_ENDCOLORS)
                ul = GETHBRUSH16(ul);
            break;

        case GCL_HCURSOR:
            ul = GETHCURSOR16(SetClassLong(hwnd, iOffset, (LONG)HCURSOR32(ul)));
            break;

        case GCL_HICON:
            ul = GETHICON16(SetClassLong(hwnd, iOffset, (LONG)HICON32(ul)));
            break;

        case GCL_HMODULE:
            ul = 0;         // not allowed to set this
            break;

        case GCL_CBWNDEXTRA:
        case GCL_STYLE:
            ul = SetClassLong(hwnd, iOffset, (LONG)ul);
            break;

        case GCL_CBCLSEXTRA:
            // apps shouldn't do this but of course some do!
            // (see GCW_CBCLSEXTRA notes in thunk for RegisterClass())
            WOW32WARNMSG(0, ("WOW:SetClassWord(): app changing cbClsExtra!"));

            // only allow this to be set by classes registered via WOW
            if(GetClassLong(hwnd, GCL_WNDPROC) & WNDPROC_WOW) { 

                // set the bozo flag 
                iOffset = GetClassLong(hwnd, GCL_CBCLSEXTRA);
                iOffset -= sizeof(DWORD);
                flag = SetClassLong(hwnd, iOffset, 1);

                // save the value the app passed 
                iOffset -= sizeof(DWORD);
                ul      = (WORD)SetClassWord(hwnd, iOffset, LOWORD(ul));

                // SetClassWord() returns the "previous" value.
                // if this is the first time the app pulls this stunt it will
                // get back the original cbClsExtra, otherwise it will get back
                // the value it stored here on the previous call.
                if(!flag) {
                    ul = iOffset; // the WOW DWORDs have already been subtracted
                }
            }
            else {
                ul = 0;  // no can do for non-WOW classes
            }
            break;

        default:
            ul = SetClassWord(hwnd, iOffset, (WORD)ul);
            break;
    }

    FREEARGPTR(parg16);
    RETURN(ul);
}
示例#6
0
WORD KappaInitKernel(HANDLE hInstance, HANDLE hPrevInstance, 
                     LPSTR lpszCmdLine, WORD cmdShow, BOOL bMulti)
{
    HCURSOR hOldCursor;

/* 0: Load the cursors */
    arrowCursor = LoadCursor(NULL, IDC_ARROW);
    hHourGlass  = LoadCursor(NULL, IDC_WAIT);
    hKcross     = LoadCursor(hInstance, "KCross");

/* Set the busy cursor */
    hOldCursor = SetCursor(hHourGlass);

/* FIRST Initialize Some External Variables */
    hInstKappa = hInstance;
    hResThisDll = hInstance;

/* 1: Load some important words into strings */
    LoadString(hInstance, IDS_BROWSER, szBrowser, 20);
    LoadString(hInstance, IDS_SESSION, szSession, 20);
#ifndef RUNTIME
    LoadString(hInstance, IDS_INTERPRET, szInterpret, 20);
    LoadString(hInstance, IDS_TRACE, szTrace, 20);
    LoadString(hInstance, IDS_KTOOLS, szKTools, 20);
    LoadString(hInstance, IDS_TOOLS, sztools, 10);
    LoadString(hInstance, IDS_INFERENCE, szInference, 20);
    LoadString(hInstance, IDS_UNTITLED, szUntitled, 11);
    LoadString(hInstance, IDS_RULEREL, szRuleRel, 30);
    LoadString(hInstance, IDS_FINDER, szFinder, 30);
    LoadString(hInstance, IDS_KALVIEW, szKalView, 30);
#endif
    
/* 2: Set up some default brushes */
    hbrWhite = GetStockObject(WHITE_BRUSH);
    hbrBlack = GetStockObject(BLACK_BRUSH);
    hbrColor = KppGetBrush(FALSE);

/* 3: Load Accelerators table */
    hAccelTable = LoadAccelerators(hInstance, szAppName);

/* 4: Remember KAPPA's starting and system directories */
    { 
        char systemdir[FILENAME_MAX];
        
        GetModuleFileName(hInstKappa, systemdir, FILENAME_MAX - 1);
        KppSetSystemDirectory(systemdir);
        
        getcwd(systemdir, FILENAME_MAX);
        KppSetStartupDirectory(systemdir);
    }
    
#ifdef CTL3D
    /* 4 (ter) Setup 3D controls if enabled in kappa.ini */
    if (Kpp3dCtrls())
        Ctl3dRegister(hInstKappa);
#endif

    /* 5: Load icons */
#ifndef RUNTIME
    kappaIcon = LoadIcon(hInstance, szAppName);
    LoadString(hInstance, IDS_BROWSERICON, szBrowserIcon, 10);
    browserIcon = LoadIcon(hInstance, szBrowserIcon);
#endif

#ifndef RUNTIME
    LoadString(hInstance, IDS_INFERENCEICON, szInferenceIcon, 10);
    inferenceIcon = LoadIcon (hInstance, szInferenceIcon);
    LoadString(hInstance, IDS_FINDERICON, szFinderIcon, 10);
    finderIcon = LoadIcon (hInstance, szFinderIcon);
    LoadString(hInstance, IDS_KALVIEWICON, szKalViewIcon, 10);
    kalviewIcon = LoadIcon (hInstance, szKalViewIcon);
    LoadString(hInstance, IDS_TRACEICON, szTraceIcon, 10);
    traceIcon = LoadIcon (hInstance, szTraceIcon);
    LoadString(hInstance, IDS_SESSIONICON, szSessionIcon, 10);
    sessionIcon = LoadIcon (hInstance, szSessionIcon);
    LoadString(hInstance, IDS_TOOLSICON, szToolsIcon, 10);
    toolsIcon = LoadIcon (hInstance, szToolsIcon);
    LoadString (hInstance, IDS_KALICON, szKALIcon, 10);
    kalIcon = LoadIcon (hInstance, szKALIcon);
    LoadString (hInstance, IDS_RULERELICON, szRuleRelIcon, 10);
    rulerelIcon = LoadIcon (hInstance, szRuleRelIcon);
#endif /* not RUNTIME */

/* 7: define screen attributes and post initial message */

/* define global system variables */
    InitSystemParams();

#ifndef RUNTIME
   if (!(hWndKappa = CreateMainWindow(hInstance)))
       return FALSE;

   SetFocus(hWndKappa);
   CreateKappaAbout(hWndKappa);
#endif

/* 8: Load the library */
    KppInitKappaKernel(hInstance, hPrevKappa, bMulti);

#ifndef RUNTIME
   /* Create a child window of the kappa window for comments. */
   hWndComment = CreateWindow("EDIT", NULL,
                              WS_CHILD | WS_BORDER | WS_HSCROLL | WS_VSCROLL |
                              ES_MULTILINE | ES_AUTOHSCROLL | ES_AUTOVSCROLL,
                              0, 0, 0, 0,
                              hWndKappa, ID_COMMENT, hInstance, NULL);

   ShowWindow(hWndComment, SW_SHOWNORMAL);
   BringWindowToTop(hWndComment);

   /* init the protected mode variable, for Global allocation */
   if (GetWinFlags() & WF_PMODE)
       bProtectedLock = TRUE;
   
#endif /* not RUNTIME */

/* Initialize alerts (do it immediately after setting up hWndKappa */
    KppInitAlert();

/* 9: intialize others */

    /* define some atoms that are often used inside KAPPA */
    InitCommonSymbols();
    
    /* Finally, initialize KAPPA functions and top level knowledge items */
    InitKappaFunctions();
    
    /* Define callback functions for the DLL's */
    InitDLLCallbackFunctions();

    /* Initialize Menu */
    KppInitMenus();
    
    /* Initialize DDE Objects */
    KppInitDDEObjectsCB();

    /* Initialize KAPPA-PC tools */
    if (!InitKappaTools(hInstance, bMulti))
        return FALSE;

    /* Reset the cursor */
    SetCursor(hOldCursor);
    
    /* Reset the clock */
    ResetClockCB();

#ifndef RUNTIME
    DestroyKappaAbout();
    SetFocus(hWndKappa);
#endif

#ifdef RUNTIME
    hWndKappa = KpsGetMainSessionWindow();

    browserIcon = NULL;
    kappaIcon = NULL;
    if (HIBYTE(LOWORD(GetVersion())) >= 10)
    {
        char stIniFileName[_MAX_PATH];

        KppGetKappaIniFile(stIniFileName, _MAX_PATH);
        if (stIniFileName[0])
        {
            char stSessIconFileName[_MAX_PATH], stBrowIconFileName[_MAX_PATH];

            GetPrivateProfileString("ICONS", "SESSION", "", 
                                    stSessIconFileName,
                                    _MAX_PATH, stIniFileName);
            GetPrivateProfileString("ICONS", "BROWSER", "", 
                                    stBrowIconFileName,
                                    _MAX_PATH, stIniFileName);
            
            if (stSessIconFileName[0] || stBrowIconFileName[0])
            {
                HANDLE hShell = GetModuleHandle("SHELL");
                BOOL bLoaded = FALSE;
                
                if (!hShell)
                {
                    GetSystemDirectory(return_buffer, RET_BUFFER_LEN);
                    strcat(return_buffer, "\\shell.dll");
                    hShell = LoadLibrary(return_buffer);
                    bLoaded = TRUE;
                }
                
                if (hShell > 32)
                {
                    HANDLE (EXPORT *ExtractIcon_fn)(HANDLE, LPSTR, WORD);

                    ExtractIcon_fn =
                        (HANDLE (EXPORT *)(HANDLE, LPSTR, WORD)) 
                            GetProcAddress(hShell, "ExtractIcon");
                    
                    if (ExtractIcon_fn)
                    {
                        if (stSessIconFileName[0])
                        {
                            kappaIcon =
                                (*ExtractIcon_fn)(hInstance,
                                                  stSessIconFileName, 0);
                            /* check for valid icon handle */
                            if (kappaIcon == 1)
                                kappaIcon = NULL;
                        }
            
                        if (stBrowIconFileName[0])
                        {
                            browserIcon =
                                (*ExtractIcon_fn)(hInstance,
                                                  stBrowIconFileName, 0);
                            /* check for valid icon handle */
                            if (browserIcon == 1)
                                browserIcon = NULL;
                        }
                    }

                    if (bLoaded)
                        FreeLibrary(hShell);
                }
            }
        }
    }
     
    if (!kappaIcon)
        kappaIcon = LoadIcon(hInstance, szAppName);
    if (!browserIcon)
    {  
        LoadString(hInstance, IDS_BROWSERICON, szBrowserIcon, 10);
        browserIcon = LoadIcon(hInstance, szBrowserIcon);
    }
    
    SetClassWord(hWndKappa, GCW_HICON, kappaIcon);
    SetClassWord(hWndBrowser, GCW_HICON, browserIcon);
#else
    PositionMainWindows();

    ShowWindow(hWndKappa, cmdShow);
    KappaBrowserMode(FALSE, cmdShow);
    ShowWindow(hWndKTools, cmdShow);
    SetFocus(hWndKappa);
#endif

    InitPopupCounts();
    MarkAppAsUnmodifiedCB();

    return TRUE;
}
/*
--------------------------------------------------------------------------
MainWndProc

This is the main procedure which processes each message.

Inputs:
  hwnd     - The handle to the parent window
  message  - Message sent from MainWndProc
  wParam   - Command from MainWndProc
  lParam   - Additional message information

Outputs:
  Used as an boolean for the current message
--------------------------------------------------------------------------
*/
int FAR PASCAL MainWndProc(HWND hwnd, WORD message, WORD wParam, LONG lParam)
{
  WORD           wTabStop;

  switch (message)
  {
    case WM_INITDIALOG:
      hWnd = hwnd;
      hWndPScroll = GetDlgItem(hWnd, IDD_PSCROLL);
      hWndCScroll = GetDlgItem(hWnd, IDD_CSCROLL);
      hWndRList   = GetDlgItem(hWnd, IDD_RLIST);
      of_course.lStructSize       = sizeof(OPENFILENAME);
      of_player.lStructSize       = sizeof(OPENFILENAME);
      of_course.hwndOwner         = hWnd;
      of_player.hwndOwner         = hWnd;
      of_course.lpstrFilter       = "Course(*.GLC)\0*.glc\0";
      of_player.lpstrFilter       = "Player(*.GLP)\0*.glp\0";
      of_course.lpstrCustomFilter = (LPSTR) NULL;
      of_player.lpstrCustomFilter = (LPSTR) NULL;
      of_course.nMaxCustFilter    = 0L;
      of_player.nMaxCustFilter    = 0L;
      of_course.nFilterIndex      = 0L;
      of_player.nFilterIndex      = 0L;
      of_course.lpstrFile         = szFileC;
      of_player.lpstrFile         = szFileP;
      of_course.nMaxFile          = sizeof(szFileC);
      of_player.nMaxFile          = sizeof(szFileP);
      of_course.lpstrFileTitle    = szFileTitleC;
      of_player.lpstrFileTitle    = szFileTitleP;
      of_course.nMaxFileTitle     = sizeof(szFileTitleC);
      of_player.nMaxFileTitle     = sizeof(szFileTitleP);
      of_course.lpstrInitialDir   = NULL;
      of_player.lpstrInitialDir   = NULL;
      of_course.nFileOffset       = 0;
      of_player.nFileOffset       = 0;
      of_course.nFileExtension    = 0;
      of_player.nFileExtension    = 0;
      of_course.lpstrDefExt       = "GLC";
      of_player.lpstrDefExt       = "GLP";
      p_index = r_index = r_last = c_index = 0;
      players.player_numb = courses.course_numb = -1;
      SetClassWord(hWnd, GCW_HICON, LoadIcon(hInst, "GOLFICON"));
      wTabStop = 4 + TAB_PIXEL_SETTING / (LOWORD(GetDialogBaseUnits()) / 4);
      SendMessage(hWndRList, LB_SETTABSTOPS, 1, (LONG) (WORD FAR *) &wTabStop);
      DoCaption(hWnd, szFileTitleP, szFileTitleC);
      return TRUE;

    case WM_INITMENU:  /* Set the menu items */
      DoMenu(wParam, &players, &courses, p_index, hWndRList);
      return TRUE;

    case WM_HSCROLL:  /* move to next or previous record */
      if (HIWORD(lParam) == hWndPScroll)
	move_player(hWnd, hWndRList, wParam, &players, &p_index, &r_index, &r_last);
      else if (HIWORD(lParam) == hWndCScroll)
	move_course(hWnd, wParam, &courses, &c_index);
      return TRUE;

    case WM_COMMAND:
      return CommandHandler(wParam, lParam);

    case WM_QUERYENDSESSION:
      if (bNeedSaveP && IDCANCEL == AskAboutSave(hWnd, szFileTitleP, PLAYER_MARKER))
	return 1;
      if (bNeedSaveC && IDCANCEL == AskAboutSave(hWnd, szFileTitleC, COURSE_MARKER))
	return 1;
      EndDialog(hWnd, NULL);
      return 0;

    case WM_CLOSE:  /* Check if file has been saved and close window */
      if (bNeedSaveP && IDCANCEL == AskAboutSave(hWnd, szFileTitleP, PLAYER_MARKER))
	return 0;
      if (bNeedSaveC && IDCANCEL == AskAboutSave(hWnd, szFileTitleC, COURSE_MARKER))
	return 0;
      EndDialog(hWnd, NULL);
      return 1;

    case WM_DESTROY:
      PostQuitMessage(0);
      return 0;

    default:
      return FALSE;
  } /* switch (message) */
} /* MainWndProc */