]>
cvs.zerfleddert.de Git - linexec-j720/blob - tester1.cpp
25571b5039229edabd6ab72683d408041382f3c0
   1 // tester1.cpp : Defines the entry point for the application. 
   7 //#include <aygshell.h> 
  11 #define MAX_LOADSTRING 100 
  14 HINSTANCE                       hInst
;                                  // The current instance 
  15 HWND                            hwndCB
;                                 // The command bar handle 
  17 //static SHACTIVATEINFO s_sai; 
  19 ATOM                            
MyRegisterClass (HINSTANCE
, LPTSTR
); 
  20 BOOL                            
InitInstance    (HINSTANCE
, int); 
  21 LRESULT CALLBACK        
WndProc                 (HWND
, UINT
, WPARAM
, LPARAM
); 
  22 LRESULT CALLBACK        
About                   (HWND
, UINT
, WPARAM
, LPARAM
); 
  23 HWND                            
CreateRpCommandBar(HWND
); 
  26 #pragma warning(disable: 4100 4710 4189; error: 4701) 
  28         4100: whining about parameters not being used. 
  29         4710: whining about screwing up inlining. 
  30         4189: initialized but not used. make that an error: later. 
  31         4701: usage w/o initialization. 
  34 int WINAPI 
WinMain(     HINSTANCE hInstance
, 
  35                                         HINSTANCE hPrevInstance
, 
  42         // Perform application initialization: 
  43         if (!InitInstance (hInstance
, nCmdShow
))  
  48         hAccelTable 
= LoadAccelerators(hInstance
, (LPCTSTR
)IDC_TESTER1
); 
  51         while (GetMessage(&msg
, NULL
, 0, 0))  
  53                 if (!TranslateAccelerator(msg
.hwnd
, hAccelTable
, &msg
))  
  55                         TranslateMessage(&msg
); 
  56                         DispatchMessage(&msg
); 
  64 //  FUNCTION: MyRegisterClass() 
  66 //  PURPOSE: Registers the window class. 
  70 //    It is important to call this function so that the application  
  71 //    will get 'well formed' small icons associated with it. 
  73 ATOM 
MyRegisterClass(HINSTANCE hInstance
, LPTSTR szWindowClass
) 
  77     wc
.style                    
= CS_HREDRAW 
| CS_VREDRAW
; 
  78     wc
.lpfnWndProc              
= (WNDPROC
) WndProc
; 
  81     wc
.hInstance                
= hInstance
; 
  82     wc
.hIcon                    
= LoadIcon(hInstance
, MAKEINTRESOURCE(IDI_TESTER1
)); 
  84     wc
.hbrBackground    
= (HBRUSH
) GetStockObject(WHITE_BRUSH
); 
  86     wc
.lpszClassName    
= szWindowClass
; 
  88         return RegisterClass(&wc
); 
  93         static HANDLE COM1handle 
= INVALID_HANDLE_VALUE
; 
  94         const char msg
[] = "\r\n--------linexec--------\r\n"; 
  96         int speed 
= CBR_115200
; 
  99         if (COM1handle 
!= INVALID_HANDLE_VALUE
) 
 102         h 
= CreateFile(TEXT("COM1:"), 
 103             GENERIC_READ 
| GENERIC_WRITE
, 0, NULL
, OPEN_EXISTING
, 0, 
 105         if (h 
== INVALID_HANDLE_VALUE
) 
 109         if (!GetCommState(h
, &dcb
)) 
 112         dcb
.BaudRate 
= speed
; 
 113         if (!SetCommState(h
, &dcb
)) 
 116         // Print banner on serial console. 
 117         WriteFile(h
, msg
, sizeof msg
, &wrote
, 0); 
 124         return (INVALID_HANDLE_VALUE
); 
 128 //  FUNCTION: InitInstance(HANDLE, int) 
 130 //  PURPOSE: Saves instance handle and creates main window 
 134 //    In this function, we save the instance handle in a global variable and 
 135 //    create and display the main program window. 
 138 BOOL 
InitInstance(HINSTANCE hInstance
, int nCmdShow
) 
 141         TCHAR   szTitle
[MAX_LOADSTRING
];                        // The title bar text 
 142         TCHAR   szWindowClass
[MAX_LOADSTRING
];          // The window class name 
 144         hInst 
= hInstance
;              // Store instance handle in our global variable 
 145         // Initialize global string 
 146         LoadString(hInstance
, IDC_TESTER1
, szWindowClass
, MAX_LOADSTRING
); 
 147         LoadString(hInstance
, IDS_APP_TITLE
, szTitle
, MAX_LOADSTRING
); 
 149         //If it is already running, then focus on the window 
 150         hWnd 
= FindWindow(szWindowClass
, szTitle
);       
 153                 SetForegroundWindow ((HWND
) (((DWORD
)hWnd
) | 0x01));     
 157         MyRegisterClass(hInstance
, szWindowClass
); 
 160         GetClientRect(hWnd
, &rect
); 
 163         load_boot("\\My Documents\\params.txt"); 
 164         load_boot("\\Storage Card\\params.txt"); 
 165         load_boot("\\Speicherkarte\\params.txt"); 
 166         load_boot("\\Carte de stockage\\params.txt"); 
 167         load_boot("\\Mes documents\\params.txt"); 
 168         load_boot("\\ÒÓØ ¶°ÄÞ\\params.txt"); 
 170         hWnd 
= CreateWindow(szWindowClass
, szTitle
, WS_VISIBLE
, 
 171                 CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, CW_USEDEFAULT
, NULL
, NULL
, hInstance
, NULL
); 
 179         //When the main window is created using CW_USEDEFAULT the height of the menubar (if one 
 180         // is created is not taken into account). So we resize the window after creating it 
 181         // if a menubar is present 
 184                 GetWindowRect(hWnd
, &rc
); 
 185                 rc
.bottom 
-= MENU_HEIGHT
; 
 187                         MoveWindow(hWnd
, rc
.left
, rc
.top
, rc
.right
, rc
.bottom
, FALSE
); 
 191         ShowWindow(hWnd
, nCmdShow
); 
 198 //  FUNCTION: WndProc(HWND, unsigned, WORD, LONG) 
 200 //  PURPOSE:  Processes messages for the main window. 
 202 //  WM_COMMAND  - process the application menu 
 203 //  WM_PAINT    - Paint the main window 
 204 //  WM_DESTROY  - post a quit message and return 
 207 LRESULT CALLBACK 
WndProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
) 
 216         TCHAR szHello
[MAX_LOADSTRING
]; 
 226                         wmId    
= LOWORD(wParam
);  
 228                         wmEvent 
= HIWORD(wParam
);  
 230                         // Parse the menu selections: 
 238                                         DialogBox(hInst
, (LPCTSTR
)IDD_ABOUTBOX
, hWnd
, (DLGPROC
)About
); 
 244                                         SendMessage(hWnd
, WM_ACTIVATE
, MAKEWPARAM(WA_INACTIVE
, 0), (LPARAM
)hWnd
); 
 246                                         SendMessage (hWnd
, WM_CLOSE
, 0, 0); 
 252                                    return DefWindowProc(hWnd
, message
, wParam
, lParam
); 
 260                         hwndCB 
= CreateRpCommandBar(hWnd
); 
 268                         hdc 
= BeginPaint(hWnd
, &ps
); 
 270                         GetClientRect(hWnd
, &rt
); 
 272                         LoadString(hInst
, IDS_HELLO
, szHello
, MAX_LOADSTRING
); 
 274                         DrawText(hdc
, szHello
, _tcslen(szHello
), &rt
,  
 276                                 DT_SINGLELINE 
| DT_VCENTER 
| DT_CENTER
); 
 284                         CommandBar_Destroy(hwndCB
); 
 290                 case WM_SETTINGCHANGE
: 
 292 //                      SHHandleWMSettingChange(hWnd, wParam, lParam, &s_sai); 
 298                         return DefWindowProc(hWnd
, message
, wParam
, lParam
); 
 308 HWND 
CreateRpCommandBar(HWND hwnd
) 
 316         memset(&mbi, 0, sizeof(SHMENUBARINFO)); 
 318         mbi.cbSize     = sizeof(SHMENUBARINFO); 
 320         mbi.hwndParent = hwnd; 
 322         mbi.nToolBarId = IDM_MENU; 
 324         mbi.hInstRes   = hInst; 
 332         if (!SHCreateMenuBar(&mbi))  
 345 // Mesage handler for the About box. 
 347 LRESULT CALLBACK 
About(HWND hDlg
, UINT message
, WPARAM wParam
, LPARAM lParam
) 
 351 //      SHINITDLGINFO shidi; 
 361                         // Create a Done button and size it.   
 363 //                      shidi.dwMask = SHIDIM_FLAGS; 
 365 //                       shidi.dwFlags = SHIDIF_DONEBUTTON | SHIDIF_SIPDOWN | SHIDIF_SIZEDLGFULLSCREEN; 
 367 //                      shidi.hDlg = hDlg; 
 369 //                      SHInitDialog(&shidi); 
 377                         if (LOWORD(wParam
) == IDOK
) { 
 379                                 EndDialog(hDlg
, LOWORD(wParam
));