#include #include #include #include #include #include #include #include #include #include /* Drag and Drop, ks. BC esx. DragDrop */ #include "wincd.h" /* Vakiot */ #define CWTITLE "WinCD" #define WTITLE WINCDTitle() #define VANHOJA 9 #define MASKEJA 9 #define TEKSTEJA 15 #define HISTORYS 20 #define UPDATE_LISTS 3333 #define FIRST_OLD 11001 #define FIRST_MASK 12001 #define FIRST_TEXT 13001 #define OLETUSMASKI "*.*" #define HISTORYITEM "History" #define POSITEM "Paikka" #define OLDITEM "Vanhat" /* Komentoriviargumenttien käsittelyssä tarvittavat muuttujat */ extern int _Cdecl _argc; extern char **_Cdecl _argv; extern char **_Cdecl environ; /************************************************************************/ /* Globaalit muuttujat: */ static HANDLE GhInstance; // static char str[255]; /* Apumerkkijono */ static char FirstInstance = 0; #if 0 LONG FAR PASCAL _export MainWndProc(HWND hWnd, unsigned message, WPARAM wParam, LPARAM lParam) { #pragma argsused // return DefWindowProc(hWnd, message, wParam, lParam); return DefDlgProc(hWnd, message, wParam, lParam); } #endif static BOOL InitInstance(HANDLE hInstance,int nCmdShow) { #pragma argsused GhInstance = hInstance; return TRUE; } /****************************************************************************/ static const char *WINCDTitle(void) { static char wtitle[50] = "WinCD mini"; return wtitle; } /****************************************************************************/ static int CountWinCDs(HANDLE hInstance) { WNDCLASS wc; /* Ikkunaluokka */ wc.style = NULL; wc.lpfnWndProc = DefDlgProc; wc.cbClsExtra = 0; wc.cbWndExtra = DLGWINDOWEXTRA; wc.hInstance = hInstance; wc.hIcon = LoadIcon(hInstance, "WINCDICON"); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = GetStockObject(WHITE_BRUSH); wc.lpszMenuName = NULL; wc.lpszClassName = "WinCDMClass"; if ( RegisterClass(&wc) ) return 0; return 1; } BOOL CALLBACK _export OpenDlg(HWND hDlg,unsigned message,WPARAM wParam,LPARAM lParam) { #pragma argsused switch (message) { case WM_DESTROY: case WM_CLOSE: PostQuitMessage(0); } return FALSE; } int PASCAL WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance, LPSTR lpCmdLine,int nCmdShow) { #pragma argsused HWND hWndOpen; if (!InitInstance(hInstance, nCmdShow)) return (FALSE); FirstInstance = (hPrevInstance == NULL); /* Jos komentoriviparametreja ei ole, näytetään Dialog Box */ if ( _argc == 1 ) { MSG msg; FARPROC lpProcOpen = MakeProcInstance((FARPROC)OpenDlg, hInstance); HACCEL hAccel = LoadAccelerators(hInstance,"PIKA"); FirstInstance = ( CountWinCDs(hInstance) == 0 ); hWndOpen = CreateDialog(hInstance,"OPEN",NULL,(DLGPROC)lpProcOpen); if ( !hWndOpen ) goto lopetus; SetWindowText(hWndOpen,WTITLE); #if 0 CreateWindow("Edit","*.*", WS_CHILD | WS_VISIBLE, 10,110,100,40,hWndOpen,(HMENU)IDC_DIRMASK,hInstance,NULL); #endif while (GetMessage(&msg,NULL,NULL,NULL)) { if ( TranslateAccelerator(hWndOpen,hAccel,&msg) ) continue; if ( IsDialogMessage(hWndOpen,&msg) ) continue; TranslateMessage(&msg); /* Tulkitaan virtuaaliset näp. koodit */ DispatchMessage(&msg); /* Lähetetään viesti ikkunalle */ } lopetus: UnregisterClass("WinCDMClass",hInstance); FreeProcInstance(lpProcOpen); return 0; } /* dir:iin hakemisto, jossa käynnistetään */ /* if(_argc>2)strcpy(dir,_argv[2]); else */ return 0; }