Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenwin32.c
Go to the documentation of this file.
00001 /* -*- c-basic-offset: 8 -*- 00002 rdesktop: A Remote Desktop Protocol client. 00003 win32 calls 00004 Copyright (C) Jay Sorg 2006 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License along 00017 with this program; if not, write to the Free Software Foundation, Inc., 00018 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 00019 */ 00020 00021 #include <winsock2.h> /* winsock2.h first */ 00022 #include <precomp.h> 00023 00024 extern char g_username[]; 00025 extern char g_hostname[]; 00026 extern char g_servername[]; 00027 extern char g_password[]; 00028 extern char g_shell[]; 00029 extern char g_directory[]; 00030 extern char g_domain[]; 00031 extern int g_width; 00032 extern int g_height; 00033 extern int g_tcp_sck; 00034 extern int g_server_depth; 00035 extern int g_tcp_port_rdp; /* in tcp.c */ 00036 extern int pal_entries[]; 00037 00038 static HWND g_Wnd = 0; 00039 static HINSTANCE g_Instance = 0; 00040 static HCURSOR g_cursor = 0; 00041 static int g_block = 0; 00042 static int g_xoff = 0; /* offset from window to client coords */ 00043 static int g_yoff = 0; 00044 static int g_xscroll = 0; /* current scroll position */ 00045 static int g_yscroll = 0; 00046 static int g_screen_width = 0; 00047 static int g_screen_height = 0; 00048 static int g_wnd_cwidth = 0; /* set from WM_SIZE */ 00049 static int g_wnd_cheight = 0; 00050 static int g_fullscreen = 0; 00051 static int g_workarea = 0; 00052 static int g_mousex = 0; /* in client coords */ 00053 static int g_mousey = 0; 00054 //static int g_width_height_set = 0; 00055 00056 static int g_clip_left = 0; 00057 static int g_clip_top = 0; 00058 static int g_clip_right = 800; 00059 static int g_clip_bottom = 600; 00060 static RECT g_wnd_clip; /* this client area of whats actually visable */ 00061 /* set from WM_SIZE */ 00062 00063 /*****************************************************************************/ 00064 static void 00065 str_to_uni(TCHAR * sizex, char * size1) 00066 { 00067 int len; 00068 int i; 00069 00070 len = strlen(size1); 00071 for (i = 0; i < len; i++) 00072 { 00073 sizex[i] = size1[i]; 00074 } 00075 sizex[len] = 0; 00076 } 00077 00078 /*****************************************************************************/ 00079 static void 00080 uni_to_str(char * sizex, TCHAR * size1) 00081 { 00082 int len; 00083 int i; 00084 00085 len = lstrlen(size1); 00086 for (i = 0; i < len; i++) 00087 { 00088 sizex[i] = (char)size1[i]; 00089 } 00090 sizex[len] = 0; 00091 } 00092 00093 /*****************************************************************************/ 00094 /* returns non zero if it processed something */ 00095 static int 00096 check_sck(void) 00097 { 00098 fd_set rfds; 00099 struct timeval tm; 00100 int count; 00101 int rv; 00102 00103 rv = 0; 00104 if (g_block == 0) 00105 { 00106 g_block = 1; 00107 /* see if there really is data */ 00108 FD_ZERO(&rfds); 00109 FD_SET((unsigned int)g_tcp_sck, &rfds); 00110 ZeroMemory(&tm, sizeof(tm)); 00111 count = select(g_tcp_sck + 1, &rfds, 0, 0, &tm); 00112 if (count > 0) 00113 { 00114 if (ui_read_wire()) 00115 { 00116 rv = 1; 00117 } 00118 else 00119 { 00120 PostQuitMessage(0); 00121 } 00122 } 00123 g_block = 0; 00124 } 00125 return rv; 00126 } 00127 00128 /*****************************************************************************/ 00129 void 00130 mi_error(char * msg) 00131 { 00132 #ifdef WITH_DEBUG 00133 printf(msg); 00134 #else /* WITH_DEBUG */ 00135 TCHAR lmsg[512]; 00136 TCHAR ltitle[512]; 00137 00138 str_to_uni(lmsg, msg); 00139 str_to_uni(ltitle, "Error"); 00140 MessageBox(g_Wnd, lmsg, ltitle, MB_OK); 00141 #endif /* WITH_DEBUG */ 00142 } 00143 00144 /*****************************************************************************/ 00145 static int 00146 get_scan_code_from_ascii(int code) 00147 { 00148 int rv; 00149 00150 rv = 0; 00151 switch (code & 0xff) 00152 { 00153 case 0x30: rv = 0x0b; break; // 0 00154 case 0x31: rv = 0x02; break; // 1 00155 case 0x32: rv = 0x03; break; // 2 00156 case 0x33: rv = 0x04; break; // 3 00157 case 0x34: rv = 0x05; break; // 4 00158 case 0x35: rv = 0x06; break; // 5 00159 case 0x36: rv = 0x07; break; // 6 00160 case 0x37: rv = 0x08; break; // 7 00161 case 0x38: rv = 0x09; break; // 8 00162 case 0x39: rv = 0x0a; break; // 9 00163 00164 case 0xbd: rv = 0x0c; break; // - 00165 case 0xbb: rv = 0x0d; break; // = 00166 case 0x08: rv = 0x0e; break; // backspace 00167 case 0x09: rv = 0x0f; break; // tab 00168 case 0xdb: rv = 0x1b; break; // ] 00169 case 0xdd: rv = 0x1a; break; // [ 00170 case 0x14: rv = 0x3a; break; // capslock 00171 case 0xba: rv = 0x27; break; // ; 00172 case 0xde: rv = 0x28; break; // ' 00173 case 0x10: rv = 0x2a; break; // shift 00174 case 0xbc: rv = 0x33; break; // , 00175 case 0xbe: rv = 0x34; break; // . 00176 case 0xbf: rv = 0x35; break; // / 00177 case 0x0d: rv = 0x1c; break; // enter 00178 case 0x27: rv = 0x4d; break; // arrow right 00179 case 0x25: rv = 0x4b; break; // arrow left 00180 case 0x26: rv = 0x48; break; // arrow up 00181 case 0x28: rv = 0x50; break; // arrow down 00182 case 0x20: rv = 0x39; break; // space 00183 case 0xdc: rv = 0x2b; break; // backslash 00184 case 0xc0: rv = 0x29; break; // ` 00185 case 0x11: rv = 0x1d; break; // ctl 00186 00187 case 0x41: rv = 0x1e; break; // a 00188 case 0x42: rv = 0x30; break; // b 00189 case 0x43: rv = 0x2e; break; // c 00190 case 0x44: rv = 0x20; break; // d 00191 case 0x45: rv = 0x12; break; // e 00192 case 0x46: rv = 0x21; break; // f 00193 case 0x47: rv = 0x22; break; // g 00194 case 0x48: rv = 0x23; break; // h 00195 case 0x49: rv = 0x17; break; // i 00196 case 0x4a: rv = 0x24; break; // j 00197 case 0x4b: rv = 0x25; break; // k 00198 case 0x4c: rv = 0x26; break; // l 00199 case 0x4d: rv = 0x32; break; // m 00200 case 0x4e: rv = 0x31; break; // n 00201 case 0x4f: rv = 0x18; break; // o 00202 case 0x50: rv = 0x19; break; // p 00203 case 0x51: rv = 0x10; break; // q 00204 case 0x52: rv = 0x13; break; // r 00205 case 0x53: rv = 0x1f; break; // s 00206 case 0x54: rv = 0x14; break; // t 00207 case 0x55: rv = 0x16; break; // u 00208 case 0x56: rv = 0x2f; break; // v 00209 case 0x57: rv = 0x11; break; // w 00210 case 0x58: rv = 0x2d; break; // x 00211 case 0x59: rv = 0x15; break; // y 00212 case 0x5a: rv = 0x2c; break; // z 00213 } 00214 return rv; 00215 } 00216 00217 /*****************************************************************************/ 00218 static void 00219 mi_scroll(int dx, int dy) 00220 { 00221 HRGN rgn; 00222 00223 rgn = CreateRectRgn(0, 0, 0, 0); 00224 ScrollWindowEx(g_Wnd, dx, dy, 0, 0, rgn, 0, SW_ERASE); 00225 InvalidateRgn(g_Wnd, rgn, 0); 00226 DeleteObject(rgn); 00227 } 00228 00229 /*****************************************************************************/ 00230 int 00231 mi_read_keyboard_state(void) 00232 { 00233 short keydata; 00234 int code; 00235 00236 code = 0; 00237 keydata = GetKeyState(VK_SCROLL); 00238 if (keydata & 0x0001) 00239 { 00240 code |= 1; 00241 } 00242 keydata = GetKeyState(VK_NUMLOCK); 00243 if (keydata & 0x0001) 00244 { 00245 code |= 2; 00246 } 00247 keydata = GetKeyState(VK_CAPITAL); 00248 if (keydata & 0x0001) 00249 { 00250 code |= 4; 00251 } 00252 return code; 00253 } 00254 00255 /*****************************************************************************/ 00256 static void 00257 mi_check_modifier(void) 00258 { 00259 int code; 00260 00261 code = mi_read_keyboard_state(); 00262 ui_set_modifier_state(code); 00263 } 00264 00265 /*****************************************************************************/ 00266 static LRESULT 00267 handle_WM_SETCURSOR(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) 00268 { 00269 if (g_mousex >= g_wnd_clip.left && 00270 g_mousey >= g_wnd_clip.top && 00271 g_mousex < g_wnd_clip.right && 00272 g_mousey < g_wnd_clip.bottom) 00273 { 00274 SetCursor(g_cursor); 00275 } 00276 /* need default behavoir here */ 00277 return DefWindowProc(hWnd, message, wParam, lParam); 00278 } 00279 00280 /*****************************************************************************/ 00281 static LRESULT 00282 handle_WM_NCHITTEST(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) 00283 { 00284 POINT pt; 00285 00286 pt.x = LOWORD(lParam); 00287 pt.y = HIWORD(lParam); 00288 if (ScreenToClient(g_Wnd, &pt)) 00289 { 00290 g_mousex = pt.x; 00291 g_mousey = pt.y; 00292 } 00293 return DefWindowProc(hWnd, message, wParam, lParam); 00294 } 00295 00296 /*****************************************************************************/ 00297 static LRESULT 00298 handle_WM_MOUSEMOVE(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) 00299 { 00300 g_mousex = LOWORD(lParam); 00301 g_mousey = HIWORD(lParam); 00302 ui_mouse_move(g_mousex + g_xscroll, g_mousey + g_yscroll); 00303 return 0; 00304 } 00305 00306 /*****************************************************************************/ 00307 static LRESULT 00308 handle_WM_LBUTTONDOWN(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) 00309 { 00310 g_mousex = LOWORD(lParam); 00311 g_mousey = HIWORD(lParam); 00312 ui_mouse_button(1, g_mousex + g_xscroll, g_mousey + g_yscroll, 1); 00313 return 0; 00314 } 00315 00316 /*****************************************************************************/ 00317 static LRESULT 00318 handle_WM_LBUTTONUP(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) 00319 { 00320 g_mousex = LOWORD(lParam); 00321 g_mousey = HIWORD(lParam); 00322 ui_mouse_button(1, g_mousex + g_xscroll, g_mousey + g_yscroll, 0); 00323 return 0; 00324 } 00325 00326 /*****************************************************************************/ 00327 static LRESULT 00328 handle_WM_RBUTTONDOWN(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) 00329 { 00330 g_mousex = LOWORD(lParam); 00331 g_mousey = HIWORD(lParam); 00332 ui_mouse_button(2, g_mousex + g_xscroll, g_mousey + g_yscroll, 1); 00333 return 0; 00334 } 00335 00336 /*****************************************************************************/ 00337 static LRESULT 00338 handle_WM_RBUTTONUP(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) 00339 { 00340 g_mousex = LOWORD(lParam); 00341 g_mousey = HIWORD(lParam); 00342 ui_mouse_button(2, g_mousex + g_xscroll, g_mousey + g_yscroll, 0); 00343 return 0; 00344 } 00345 00346 /*****************************************************************************/ 00347 static LRESULT 00348 handle_WM_MBUTTONDOWN(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) 00349 { 00350 g_mousex = LOWORD(lParam); 00351 g_mousey = HIWORD(lParam); 00352 ui_mouse_button(3, g_mousex + g_xscroll, g_mousey + g_yscroll, 1); 00353 return 0; 00354 } 00355 00356 /*****************************************************************************/ 00357 static LRESULT 00358 handle_WM_MBUTTONUP(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) 00359 { 00360 g_mousex = LOWORD(lParam); 00361 g_mousey = HIWORD(lParam); 00362 ui_mouse_button(3, g_mousex + g_xscroll, g_mousey + g_yscroll, 0); 00363 return 0; 00364 } 00365 00366 /*****************************************************************************/ 00367 static LRESULT 00368 handle_WM_MOUSEWHEEL(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) 00369 { 00370 int delta; 00371 00372 delta = ((signed short)HIWORD(wParam)); /* GET_WHEEL_DELTA_WPARAM(wParam); */ 00373 if (delta > 0) 00374 { 00375 ui_mouse_button(4, 0, 0, 1); 00376 ui_mouse_button(4, 0, 0, 0); 00377 } 00378 else 00379 { 00380 ui_mouse_button(5, 0, 0, 1); 00381 ui_mouse_button(5, 0, 0, 0); 00382 } 00383 return 0; 00384 } 00385 00386 /*****************************************************************************/ 00387 static LRESULT 00388 handle_WM_KEY(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) 00389 { 00390 int scancode; 00391 int ext; 00392 int down; 00393 00394 ext = HIWORD(lParam); 00395 scancode = ext; 00396 down = !(ext & 0x8000); 00397 scancode &= 0xff; 00398 if (scancode == 0) 00399 { 00400 scancode = get_scan_code_from_ascii(wParam); 00401 } 00402 ext &= 0x0100; 00403 if (scancode == 0x0045) /* num lock */ 00404 { 00405 ext &= ~0x0100; 00406 } 00407 if (down) 00408 { 00409 ui_key_down(scancode, ext); 00410 } 00411 else 00412 { 00413 ui_key_up(scancode, ext); 00414 } 00415 return 0; 00416 } 00417 00418 /*****************************************************************************/ 00419 static LRESULT 00420 handle_WM_PAINT(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) 00421 { 00422 PAINTSTRUCT ps; 00423 RECT rect; 00424 HBRUSH brush; 00425 00426 BeginPaint(hWnd, &ps); 00427 /* paint the area outside the rdp screen with one colour */ 00428 rect = ps.rcPaint; 00429 rect.left = UI_MAX(rect.left, g_width); 00430 if (!IsRectEmpty(&rect)) 00431 { 00432 brush = CreateSolidBrush(RGB(0, 0, 255)); 00433 FillRect(ps.hdc, &rect, brush); 00434 DeleteObject(brush); 00435 } 00436 rect = ps.rcPaint; 00437 rect.top = UI_MAX(rect.top, g_height); 00438 if (!IsRectEmpty(&rect)) 00439 { 00440 brush = CreateSolidBrush(RGB(0, 0, 255)); 00441 FillRect(ps.hdc, &rect, brush); 00442 DeleteObject(brush); 00443 } 00444 rect = ps.rcPaint; 00445 EndPaint(hWnd, &ps); 00446 ui_invalidate(rect.left + g_xscroll, 00447 rect.top + g_yscroll, 00448 (rect.right - rect.left) + 1, 00449 (rect.bottom - rect.top) + 1); 00450 return 0; 00451 } 00452 00453 /*****************************************************************************/ 00454 static LRESULT 00455 handle_WM_SIZE(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) 00456 { 00457 int oldxscroll; 00458 int oldyscroll; 00459 00460 if (wParam == SIZE_MINIMIZED) 00461 { 00462 return DefWindowProc(hWnd, message, wParam, lParam); 00463 } 00464 g_wnd_cwidth = LOWORD(lParam); /* client width / height */ 00465 g_wnd_cheight = HIWORD(lParam); 00466 g_wnd_clip.left = 0; 00467 g_wnd_clip.top = 0; 00468 g_wnd_clip.right = g_wnd_clip.left + g_wnd_cwidth; 00469 g_wnd_clip.bottom = g_wnd_clip.top + g_wnd_cheight; 00470 if (g_wnd_cwidth < g_width || g_wnd_cheight < g_height) 00471 { 00472 SetScrollRange(g_Wnd, SB_HORZ, 0, g_width - g_wnd_cwidth, 1); 00473 SetScrollRange(g_Wnd, SB_VERT, 0, g_height - g_wnd_cheight, 1); 00474 } 00475 oldxscroll = g_xscroll; 00476 oldyscroll = g_yscroll; 00477 if (g_wnd_cwidth >= g_width) 00478 { 00479 g_xscroll = 0; 00480 } 00481 else 00482 { 00483 g_xscroll = UI_MIN(g_xscroll, g_width - g_wnd_cwidth); 00484 } 00485 if (g_wnd_cheight >= g_height) 00486 { 00487 g_yscroll = 0; 00488 } 00489 else 00490 { 00491 g_yscroll = UI_MIN(g_yscroll, g_height - g_wnd_cheight); 00492 } 00493 mi_scroll(oldxscroll - g_xscroll, oldyscroll - g_yscroll); 00494 if (wParam == SIZE_RESTORED || wParam == SIZE_MAXIMIZED) 00495 { 00496 /* check the caps, num, and scroll lock here */ 00497 mi_check_modifier(); 00498 } 00499 return 0; 00500 } 00501 00502 /*****************************************************************************/ 00503 static LRESULT 00504 handle_WM_SIZING(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) 00505 { 00506 LPRECT prect; 00507 int width; 00508 int height; 00509 int style; 00510 00511 prect = (LPRECT) lParam; /* total window rect */ 00512 width = (prect->right - prect->left) - (g_xoff * 2); 00513 height = (prect->bottom - prect->top) - (g_yoff + g_xoff); 00514 if (height < g_height || width < g_width) 00515 { 00516 style = GetWindowLongPtr(g_Wnd, GWL_STYLE); 00517 if (!(style & WS_HSCROLL)) 00518 { 00519 style |= WS_HSCROLL | WS_VSCROLL; 00520 SetWindowLongPtr(g_Wnd, GWL_STYLE, style); 00521 g_xscroll = 0; 00522 g_yscroll = 0; 00523 SetScrollPos(g_Wnd, SB_HORZ, g_xscroll, 1); 00524 SetScrollPos(g_Wnd, SB_VERT, g_yscroll, 1); 00525 } 00526 } 00527 else if (height >= g_height && width >= g_width) 00528 { 00529 style = GetWindowLongPtr(g_Wnd, GWL_STYLE); 00530 if (style & WS_HSCROLL) 00531 { 00532 style &= ~WS_HSCROLL; 00533 style &= ~WS_VSCROLL; 00534 SetWindowLongPtr(g_Wnd, GWL_STYLE, style); 00535 g_xscroll = 0; 00536 g_yscroll = 0; 00537 } 00538 } 00539 return 0; 00540 } 00541 00542 /*****************************************************************************/ 00543 static LRESULT 00544 handle_WM_HSCROLL(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) 00545 { 00546 int code; 00547 int oldxscroll; 00548 00549 code = (int) LOWORD(wParam); /* scroll bar value */ 00550 if (code == SB_LINELEFT) 00551 { 00552 oldxscroll = g_xscroll; 00553 g_xscroll--; 00554 g_xscroll = UI_MAX(g_xscroll, 0); 00555 SetScrollPos(g_Wnd, SB_HORZ, g_xscroll, 1); 00556 mi_scroll(oldxscroll - g_xscroll, 0); 00557 } 00558 else if (code == SB_LINERIGHT) 00559 { 00560 oldxscroll = g_xscroll; 00561 g_xscroll++; 00562 g_xscroll = UI_MIN(g_xscroll, g_width - g_wnd_cwidth); 00563 SetScrollPos(g_Wnd, SB_HORZ, g_xscroll, 1); 00564 mi_scroll(oldxscroll - g_xscroll, 0); 00565 } 00566 else if (code == SB_PAGELEFT) 00567 { 00568 oldxscroll = g_xscroll; 00569 g_xscroll -= g_wnd_cwidth / 2; 00570 g_xscroll = UI_MAX(g_xscroll, 0); 00571 SetScrollPos(g_Wnd, SB_HORZ, g_xscroll, 1); 00572 mi_scroll(oldxscroll - g_xscroll, 0); 00573 } 00574 else if (code == SB_PAGERIGHT) 00575 { 00576 oldxscroll = g_xscroll; 00577 g_xscroll += g_wnd_cwidth / 2; 00578 g_xscroll = UI_MIN(g_xscroll, g_width - g_wnd_cwidth); 00579 SetScrollPos(g_Wnd, SB_HORZ, g_xscroll, 1); 00580 mi_scroll(oldxscroll - g_xscroll, 0); 00581 } 00582 else if (code == SB_BOTTOM) 00583 { 00584 oldxscroll = g_xscroll; 00585 g_xscroll = g_width - g_wnd_cwidth; 00586 SetScrollPos(g_Wnd, SB_HORZ, g_xscroll, 1); 00587 mi_scroll(oldxscroll - g_xscroll, 0); 00588 } 00589 else if (code == SB_TOP) 00590 { 00591 oldxscroll = g_xscroll; 00592 g_xscroll = 0; 00593 SetScrollPos(g_Wnd, SB_HORZ, g_xscroll, 1); 00594 mi_scroll(oldxscroll - g_xscroll, 0); 00595 } 00596 else if (code == SB_THUMBPOSITION) 00597 { 00598 oldxscroll = g_xscroll; 00599 g_xscroll = (signed short) HIWORD(wParam); 00600 SetScrollPos(g_Wnd, SB_HORZ, g_xscroll, 1); 00601 mi_scroll(oldxscroll - g_xscroll, 0); 00602 } 00603 return 0; 00604 } 00605 00606 /*****************************************************************************/ 00607 static LRESULT 00608 handle_WM_VSCROLL(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) 00609 { 00610 int code; 00611 int oldyscroll; 00612 00613 code = (int) LOWORD(wParam); /* scroll bar value */ 00614 if (code == SB_LINELEFT) 00615 { 00616 oldyscroll = g_yscroll; 00617 g_yscroll--; 00618 g_yscroll = UI_MAX(g_yscroll, 0); 00619 SetScrollPos(g_Wnd, SB_VERT, g_yscroll, 1); 00620 mi_scroll(0, oldyscroll - g_yscroll); 00621 } 00622 else if (code == SB_LINERIGHT) 00623 { 00624 oldyscroll = g_yscroll; 00625 g_yscroll++; 00626 g_yscroll = UI_MIN(g_yscroll, g_height - g_wnd_cheight); 00627 SetScrollPos(g_Wnd, SB_VERT, g_yscroll, 1); 00628 mi_scroll(0, oldyscroll - g_yscroll); 00629 } 00630 else if (code == SB_PAGELEFT) 00631 { 00632 oldyscroll = g_yscroll; 00633 g_yscroll -= g_wnd_cheight / 2; 00634 g_yscroll = UI_MAX(g_yscroll, 0); 00635 SetScrollPos(g_Wnd, SB_VERT, g_yscroll, 1); 00636 mi_scroll(0, oldyscroll - g_yscroll); 00637 } 00638 else if (code == SB_PAGERIGHT) 00639 { 00640 oldyscroll = g_yscroll; 00641 g_yscroll += g_wnd_cheight / 2; 00642 g_yscroll = UI_MIN(g_yscroll, g_height - g_wnd_cheight); 00643 SetScrollPos(g_Wnd, SB_VERT, g_yscroll, 1); 00644 mi_scroll(0, oldyscroll - g_yscroll); 00645 } 00646 else if (code == SB_BOTTOM) 00647 { 00648 oldyscroll = g_yscroll; 00649 g_yscroll = g_height - g_wnd_cheight; 00650 SetScrollPos(g_Wnd, SB_VERT, g_yscroll, 1); 00651 mi_scroll(0, oldyscroll - g_yscroll); 00652 } 00653 else if (code == SB_TOP) 00654 { 00655 oldyscroll = g_yscroll; 00656 g_yscroll = 0; 00657 SetScrollPos(g_Wnd, SB_VERT, g_yscroll, 1); 00658 mi_scroll(0, oldyscroll - g_yscroll); 00659 } 00660 else if (code == SB_THUMBPOSITION) 00661 { 00662 oldyscroll = g_yscroll; 00663 g_yscroll = (signed short) HIWORD(wParam); 00664 SetScrollPos(g_Wnd, SB_VERT, g_yscroll, 1); 00665 mi_scroll(0, oldyscroll - g_yscroll); 00666 } 00667 return 0; 00668 } 00669 00670 00671 /*****************************************************************************/ 00672 LRESULT CALLBACK 00673 WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) 00674 { 00675 switch (message) 00676 { 00677 case WM_SETCURSOR: 00678 return handle_WM_SETCURSOR(hWnd, message, wParam, lParam); 00679 case 0x0084: /* WinCE don't have this WM_NCHITTEST: */ 00680 return handle_WM_NCHITTEST(hWnd, message, wParam, lParam); 00681 case WM_MOUSEMOVE: 00682 return handle_WM_MOUSEMOVE(hWnd, message, wParam, lParam); 00683 case WM_LBUTTONDOWN: 00684 return handle_WM_LBUTTONDOWN(hWnd, message, wParam, lParam); 00685 case WM_LBUTTONUP: 00686 return handle_WM_LBUTTONUP(hWnd, message, wParam, lParam); 00687 case WM_RBUTTONDOWN: 00688 return handle_WM_RBUTTONDOWN(hWnd, message, wParam, lParam); 00689 case WM_RBUTTONUP: 00690 return handle_WM_RBUTTONUP(hWnd, message, wParam, lParam); 00691 case WM_MBUTTONDOWN: 00692 return handle_WM_MBUTTONDOWN(hWnd, message, wParam, lParam); 00693 case WM_MBUTTONUP: 00694 return handle_WM_MBUTTONUP(hWnd, message, wParam, lParam); 00695 /* some windows compilers don't have these defined like vc6 */ 00696 case 0x020a: /* WM_MOUSEWHEEL: */ 00697 return handle_WM_MOUSEWHEEL(hWnd, message, wParam, lParam); 00698 case WM_KEYDOWN: 00699 case WM_KEYUP: 00700 case WM_SYSKEYDOWN: 00701 case WM_SYSKEYUP: 00702 return handle_WM_KEY(hWnd, message, wParam, lParam); 00703 case WM_CHAR: 00704 case WM_DEADCHAR: 00705 case WM_SYSCHAR: 00706 case WM_SYSDEADCHAR: 00707 break; 00708 case WM_PAINT: 00709 return handle_WM_PAINT(hWnd, message, wParam, lParam); 00710 case WM_DESTROY: 00711 PostQuitMessage(0); 00712 break; 00713 case WM_APP + 1: 00714 case WM_TIMER: 00715 check_sck(); 00716 break; 00717 case WM_SIZE: 00718 return handle_WM_SIZE(hWnd, message, wParam, lParam); 00719 case 532: /* not defined in wince WM_SIZING: */ 00720 return handle_WM_SIZING(hWnd, message, wParam, lParam); 00721 case WM_HSCROLL: 00722 return handle_WM_HSCROLL(hWnd, message, wParam, lParam); 00723 case WM_VSCROLL: 00724 return handle_WM_VSCROLL(hWnd, message, wParam, lParam); 00725 case WM_SETFOCUS: 00726 mi_check_modifier(); 00727 return DefWindowProc(hWnd, message, wParam, lParam); 00728 default: 00729 return DefWindowProc(hWnd, message, wParam, lParam); 00730 } 00731 return 0; 00732 } 00733 00734 /*****************************************************************************/ 00735 static HRGN 00736 mi_clip(HDC dc) 00737 { 00738 HRGN rgn; 00739 00740 rgn = CreateRectRgn(g_clip_left + g_xoff - g_xscroll, 00741 g_clip_top + g_yoff - g_yscroll, 00742 g_clip_right + g_xoff - g_xscroll, 00743 g_clip_bottom + g_yoff - g_yscroll); 00744 SelectClipRgn(dc, rgn); 00745 IntersectClipRect(dc, g_wnd_clip.left + g_xoff, g_wnd_clip.top + g_yoff, 00746 g_wnd_clip.right + g_xoff, g_wnd_clip.bottom + g_yoff); 00747 return rgn; 00748 } 00749 00750 /*****************************************************************************/ 00751 /* returns non zero if ok */ 00752 int 00753 mi_create_window(void) 00754 { 00755 RECT rc; 00756 WNDCLASS wc; 00757 TCHAR classname[512]; 00758 TCHAR caption[512]; 00759 DWORD style; 00760 int x; 00761 int y; 00762 int w; 00763 int h; 00764 00765 if (g_Wnd != 0 || g_Instance != 0) 00766 { 00767 return 0; 00768 } 00769 g_Instance = GetModuleHandle(NULL); 00770 ZeroMemory(&wc, sizeof(wc)); 00771 wc.lpfnWndProc = WndProc; /* points to window procedure */ 00772 /* name of window class */ 00773 str_to_uni(classname, "rdesktop"); 00774 wc.lpszClassName = classname; 00775 str_to_uni(caption, "ReactOS Remote Desktop"); 00776 wc.hIcon = LoadIcon(g_Instance, 00777 MAKEINTRESOURCE(IDI_MSTSC)); 00778 /* Register the window class. */ 00779 if (!RegisterClass(&wc)) 00780 { 00781 return 0; /* Failed to register window class */ 00782 } 00783 rc.left = 0; 00784 rc.right = rc.left + UI_MIN(g_width, g_screen_width); 00785 rc.top = 0; 00786 rc.bottom = rc.top + UI_MIN(g_height, g_screen_height); 00787 00788 if (g_fullscreen) 00789 { 00790 style = WS_POPUP; 00791 } 00792 else 00793 { 00794 style = WS_OVERLAPPED | WS_CAPTION | WS_POPUP | WS_MINIMIZEBOX | 00795 WS_SYSMENU | WS_SIZEBOX | WS_MAXIMIZEBOX; 00796 } 00797 if (g_screen_width < g_width || g_screen_height < g_height) 00798 { 00799 style |= WS_HSCROLL | WS_VSCROLL; 00800 } 00801 AdjustWindowRectEx(&rc, style, 0, 0); 00802 x = CW_USEDEFAULT; 00803 y = CW_USEDEFAULT; 00804 w = rc.right - rc.left; 00805 h = rc.bottom - rc.top; 00806 00807 g_Wnd = CreateWindow(wc.lpszClassName, caption, 00808 style, x, y, w, h, 00809 (HWND) NULL, (HMENU) NULL, g_Instance, 00810 (LPVOID) NULL); 00811 g_clip_left = 0; 00812 g_clip_top = 0; 00813 g_clip_right = g_clip_left + g_width; 00814 g_clip_bottom = g_clip_top + g_height; 00815 if (g_workarea) 00816 { 00817 ShowWindow(g_Wnd, SW_SHOWMAXIMIZED); 00818 } 00819 else 00820 { 00821 ShowWindow(g_Wnd, SW_SHOWNORMAL); 00822 } 00823 UpdateWindow(g_Wnd); 00824 00825 WSAAsyncSelect(g_tcp_sck, g_Wnd, WM_APP + 1, FD_READ); 00826 SetTimer(g_Wnd, 1, 333, 0); 00827 00828 return 1; 00829 } 00830 00831 /*****************************************************************************/ 00832 int 00833 mi_main_loop(void) 00834 { 00835 MSG msg; 00836 00837 while (GetMessage(&msg, NULL, 0, 0)) 00838 { 00839 TranslateMessage(&msg); 00840 DispatchMessage(&msg); 00841 } 00842 return msg.wParam; 00843 } 00844 00845 /*****************************************************************************/ 00846 void 00847 mi_warning(char * msg) 00848 { 00849 } 00850 00851 /*****************************************************************************/ 00852 static void 00853 mi_show_error(char * caption) 00854 { 00855 LPVOID lpMsgBuf; 00856 TCHAR lcaption[512]; 00857 00858 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, 00859 NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), 00860 (LPTSTR) &lpMsgBuf, 0, NULL); 00861 #ifdef WITH_DEBUG 00862 printf(lpMsgBuf); 00863 #else /* WITH_DEBUG */ 00864 str_to_uni(lcaption, caption); 00865 MessageBox(g_Wnd, (LPTSTR) lpMsgBuf, lcaption, 00866 MB_OK | MB_ICONINFORMATION); 00867 #endif /* WITH_DEBUG */ 00868 LocalFree(lpMsgBuf); 00869 } 00870 00871 /*****************************************************************************/ 00872 void 00873 mi_paint_rect(char * data, int width, int height, int x, int y, int cx, int cy) 00874 { 00875 HBITMAP bitmap; 00876 BITMAPINFO bi; 00877 HDC dc; 00878 HDC maindc; 00879 HGDIOBJ save; 00880 HRGN rgn; 00881 void * bits; 00882 int i; 00883 int j; 00884 int colour; 00885 int red; 00886 int green; 00887 int blue; 00888 00889 ZeroMemory(&bi, sizeof(bi)); 00890 bi.bmiHeader.biSize = sizeof(bi.bmiHeader); 00891 bi.bmiHeader.biWidth = width; 00892 bi.bmiHeader.biHeight = -height; 00893 bi.bmiHeader.biPlanes = 1; 00894 bi.bmiHeader.biBitCount = 32; 00895 bi.bmiHeader.biCompression = BI_RGB; 00896 maindc = GetWindowDC(g_Wnd); 00897 bitmap = CreateDIBSection(maindc, &bi, DIB_RGB_COLORS, (void **) &bits, 0, 0); 00898 if (bitmap == 0) 00899 { 00900 mi_show_error("CreateDIBSection failed"); 00901 } 00902 00903 if (g_server_depth == 8) 00904 { 00905 for (i = cy - 1; i >= 0; i--) 00906 { 00907 for (j = cx - 1; j >= 0; j--) 00908 { 00909 colour = ((unsigned char*)data)[i * cx + j]; 00910 red = (pal_entries[colour & 0xff] & 0xff0000) >> 16; 00911 green = (pal_entries[colour & 0xff] & 0xff00) >> 8; 00912 blue = pal_entries[colour & 0xff] & 0xff; 00913 MAKE_COLOUR32(colour, red, green, blue); 00914 ((unsigned int*)bits)[i * cx + j] = colour; 00915 } 00916 } 00917 } 00918 else if (g_server_depth == 15) 00919 { 00920 for (i = cy - 1; i >= 0; i--) 00921 { 00922 for (j = cx - 1; j >= 0; j--) 00923 { 00924 colour = ((unsigned short*)data)[i * cx + j]; 00925 SPLIT_COLOUR15(colour, red, green, blue); 00926 MAKE_COLOUR32(colour, red, green, blue); 00927 ((unsigned int*)bits)[i * cx + j] = colour; 00928 } 00929 } 00930 } 00931 else if (g_server_depth == 16) 00932 { 00933 for (i = cy - 1; i >= 0; i--) 00934 { 00935 for (j = cx - 1; j >= 0; j--) 00936 { 00937 colour = ((unsigned short*)data)[i * cx + j]; 00938 SPLIT_COLOUR16(colour, red, green, blue); 00939 MAKE_COLOUR32(colour, red, green, blue); 00940 ((unsigned int*)bits)[i * cx + j] = colour; 00941 } 00942 } 00943 } 00944 dc = CreateCompatibleDC(maindc); 00945 if (dc == 0) 00946 { 00947 mi_show_error("CreateCompatibleDC failed"); 00948 } 00949 save = SelectObject(dc, bitmap); 00950 rgn = mi_clip(maindc); 00951 BitBlt(maindc, x + g_xoff - g_xscroll, y + g_yoff - g_yscroll, cx, cy, dc, 00952 0, 0, SRCCOPY); 00953 SelectObject(dc, save); 00954 DeleteObject(bitmap); 00955 DeleteDC(dc); 00956 ReleaseDC(g_Wnd, maindc); 00957 DeleteObject(rgn); 00958 00959 } 00960 00961 static INT 00962 GetPortNumber(PCHAR szAddress) 00963 { 00964 PCHAR szPort; 00965 INT iPort = TCP_PORT_RDP; 00966 00967 szPort = strtok(szAddress, ":"); 00968 00969 if (szPort != NULL) 00970 { 00971 szPort = strtok(NULL, ":"); 00972 00973 if (szPort != NULL) 00974 { 00975 iPort = atoi(szPort); 00976 00977 if (iPort <= 0 || iPort > 0xFFFF) 00978 iPort = TCP_PORT_RDP; 00979 } 00980 } 00981 00982 return iPort; 00983 } 00984 00985 static VOID 00986 SetDomainAndUsername(PCHAR pName) 00987 { 00988 PCHAR pDomain; 00989 PCHAR pUsername; 00990 00991 strcpy(g_domain, ""); 00992 strcpy(g_username, ""); 00993 00994 pDomain = strtok(pName, "\\"); 00995 00996 if(pDomain == NULL) 00997 return; 00998 00999 pUsername = strtok(NULL, "\\"); 01000 01001 if(pUsername == NULL) 01002 { 01003 strcpy(g_username, pDomain); 01004 return; 01005 } 01006 01007 strcpy(g_username, pUsername); 01008 strcpy(g_domain, pDomain); 01009 return; 01010 } 01011 01012 static BOOL 01013 ParseCommandLine(LPWSTR lpCmdLine, 01014 PRDPSETTINGS pRdpSettings, 01015 BOOL *bSkipDlg) 01016 { 01017 LPWSTR lpStr = lpCmdLine; 01018 WCHAR szSeps[] = L"/"; 01019 LPWSTR lpToken; 01020 BOOL bRet = TRUE; 01021 01022 *bSkipDlg = TRUE; 01023 01024 if (*lpCmdLine != L'/') 01025 { 01026 LoadRdpSettingsFromFile(pRdpSettings, lpCmdLine); 01027 } 01028 else 01029 { 01030 /* default to screen size, 16bpp */ 01031 SetIntegerToSettings(pRdpSettings, L"session bpp", 16); 01032 SetIntegerToSettings(pRdpSettings, L"desktopwidth", GetSystemMetrics(SM_CXSCREEN)); 01033 SetIntegerToSettings(pRdpSettings, L"desktopheight", GetSystemMetrics(SM_CYSCREEN)); 01034 01035 lpToken = wcstok(lpStr, szSeps); 01036 while (lpToken) 01037 { 01038 if (wcsncmp(lpToken, L"edit", 4) == 0) 01039 { 01040 lpToken += 5; 01041 LoadRdpSettingsFromFile(pRdpSettings, lpToken); 01042 *bSkipDlg = FALSE; 01043 break; 01044 } 01045 01046 if (*lpToken == L'v') 01047 { 01048 lpToken += 2; 01049 SetStringToSettings(pRdpSettings, L"full address", lpToken); 01050 } 01051 else if (*lpToken == L'w') 01052 { 01053 lpToken += 2; 01054 SetIntegerToSettings(pRdpSettings, L"desktopwidth", _wtoi(lpToken)); 01055 } 01056 else if (*lpToken == L'h') 01057 { 01058 lpToken += 2; 01059 SetIntegerToSettings(pRdpSettings, L"desktopheight", _wtoi(lpToken)); 01060 } 01061 else if (*lpToken == L'f') 01062 { 01063 SetIntegerToSettings(pRdpSettings, L"screen mode id", 2); 01064 } 01065 01066 lpToken = wcstok(NULL, szSeps); 01067 } 01068 } 01069 01070 return bRet; 01071 } 01072 01073 /*****************************************************************************/ 01074 int WINAPI 01075 wWinMain(HINSTANCE hInstance, 01076 HINSTANCE hPrevInstance, 01077 LPWSTR lpCmdLine, 01078 int nCmdShow) 01079 { 01080 PRDPSETTINGS pRdpSettings; 01081 WSADATA d; 01082 int ret = 1; 01083 01084 if (WSAStartup(MAKEWORD(2, 0), &d) == 0) 01085 { 01086 pRdpSettings = HeapAlloc(GetProcessHeap(), 01087 0, 01088 sizeof(RDPSETTINGS)); 01089 if (pRdpSettings) 01090 { 01091 pRdpSettings->pSettings = NULL; 01092 pRdpSettings->NumSettings = 0; 01093 01094 if (InitRdpSettings(pRdpSettings)) 01095 { 01096 BOOL bSkipDlg = FALSE; 01097 01098 if (*lpCmdLine) 01099 ParseCommandLine(lpCmdLine, pRdpSettings,&bSkipDlg); 01100 else 01101 LoadRdpSettingsFromFile(pRdpSettings, NULL); 01102 01103 if (bSkipDlg || OpenRDPConnectDialog(hInstance, 01104 pRdpSettings)) 01105 { 01106 char szValue[MAXVALUE]; 01107 01108 uni_to_str(szValue, GetStringFromSettings(pRdpSettings, L"full address")); 01109 01110 /* GetPortNumber also removes possible trailing port number from address */ 01111 g_tcp_port_rdp = GetPortNumber(szValue); 01112 strcpy(g_servername, szValue); 01113 uni_to_str(szValue, GetStringFromSettings(pRdpSettings, L"username")); 01114 SetDomainAndUsername(szValue); 01115 strcpy(g_password, ""); 01116 g_server_depth = GetIntegerFromSettings(pRdpSettings, L"session bpp"); 01117 if (g_server_depth > 16) g_server_depth = 16; /* hack, we don't support 24bpp yet */ 01118 g_screen_width = GetSystemMetrics(SM_CXSCREEN); 01119 g_screen_height = GetSystemMetrics(SM_CYSCREEN); 01120 g_width = GetIntegerFromSettings(pRdpSettings, L"desktopwidth"); 01121 g_height = GetIntegerFromSettings(pRdpSettings, L"desktopheight"); 01122 if (GetIntegerFromSettings(pRdpSettings, L"screen mode id") == 2) 01123 { 01124 g_fullscreen = 1; 01125 g_xoff = 0; 01126 g_yoff = 0; 01127 } 01128 else 01129 { 01130 g_xoff = GetSystemMetrics(SM_CXEDGE) * 2; 01131 g_yoff = GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYEDGE) * 2; 01132 } 01133 01134 ui_main(); 01135 ret = 0; 01136 } 01137 01138 HeapFree(GetProcessHeap(), 01139 0, 01140 pRdpSettings->pSettings); 01141 } 01142 01143 HeapFree(GetProcessHeap(), 01144 0, 01145 pRdpSettings); 01146 } 01147 01148 WSACleanup(); 01149 } 01150 01151 return ret; 01152 } 01153 01154 01155 /*****************************************************************************/ 01156 void 01157 mi_begin_update(void) 01158 { 01159 } 01160 01161 /*****************************************************************************/ 01162 void 01163 mi_end_update(void) 01164 { 01165 } 01166 01167 /*****************************************************************************/ 01168 void 01169 mi_fill_rect(int x, int y, int cx, int cy, int colour) 01170 { 01171 HBRUSH brush; 01172 RECT rect; 01173 HDC maindc; 01174 HRGN rgn; 01175 int red; 01176 int green; 01177 int blue; 01178 01179 if (g_server_depth == 8) 01180 { 01181 red = (pal_entries[colour & 0xff] & 0xff0000) >> 16; 01182 green = (pal_entries[colour & 0xff] & 0xff00) >> 8; 01183 blue = pal_entries[colour & 0xff] & 0xff; 01184 } 01185 else if (g_server_depth == 15) 01186 { 01187 SPLIT_COLOUR15(colour, red, green, blue); 01188 } 01189 else if (g_server_depth == 16) 01190 { 01191 SPLIT_COLOUR16(colour, red, green, blue); 01192 } 01193 else 01194 { 01195 red = 0; 01196 green = 0; 01197 blue = 0; 01198 } 01199 maindc = GetWindowDC(g_Wnd); 01200 rgn = mi_clip(maindc); 01201 brush = CreateSolidBrush(RGB(red, green, blue)); 01202 rect.left = x + g_xoff - g_xscroll; 01203 rect.top = y + g_yoff - g_yscroll; 01204 rect.right = rect.left + cx; 01205 rect.bottom = rect.top + cy; 01206 FillRect(maindc, &rect, brush); 01207 DeleteObject(brush); 01208 ReleaseDC(g_Wnd, maindc); 01209 DeleteObject(rgn); 01210 } 01211 01212 /*****************************************************************************/ 01213 void 01214 mi_line(int x1, int y1, int x2, int y2, int colour) 01215 { 01216 HPEN pen; 01217 HDC maindc; 01218 HGDIOBJ save; 01219 HRGN rgn; 01220 int red; 01221 int green; 01222 int blue; 01223 01224 if (g_server_depth == 8) 01225 { 01226 red = (pal_entries[colour & 0xff] & 0xff0000) >> 16; 01227 green = (pal_entries[colour & 0xff] & 0xff00) >> 8; 01228 blue = pal_entries[colour & 0xff] & 0xff; 01229 } 01230 else if (g_server_depth == 15) 01231 { 01232 SPLIT_COLOUR15(colour, red, green, blue); 01233 } 01234 else if (g_server_depth == 16) 01235 { 01236 SPLIT_COLOUR16(colour, red, green, blue); 01237 } 01238 else 01239 { 01240 red = 0; 01241 green = 0; 01242 blue = 0; 01243 } 01244 maindc = GetWindowDC(g_Wnd); 01245 rgn = mi_clip(maindc); 01246 pen = CreatePen(PS_SOLID, 0, RGB(red, green, blue)); 01247 save = SelectObject(maindc, pen); 01248 MoveToEx(maindc, x1 + g_xoff - g_xscroll, y1 + g_yoff - g_yscroll, 0); 01249 LineTo(maindc, x2 + g_xoff - g_xscroll, y2 + g_yoff - g_yscroll); 01250 SelectObject(maindc, save); 01251 DeleteObject(pen); 01252 ReleaseDC(g_Wnd, maindc); 01253 DeleteObject(rgn); 01254 } 01255 01256 /*****************************************************************************/ 01257 void 01258 mi_screen_copy(int x, int y, int cx, int cy, int srcx, int srcy) 01259 { 01260 RECT rect; 01261 RECT clip_rect; 01262 RECT draw_rect; 01263 HRGN rgn; 01264 int ok_to_ScrollWindowEx; 01265 01266 ok_to_ScrollWindowEx = 1; 01267 01268 if (!ok_to_ScrollWindowEx) 01269 { 01270 rgn = CreateRectRgn(x - g_xscroll, y - g_yscroll, 01271 (x - g_xscroll) + cx, 01272 (y - g_yscroll) + cy); 01273 InvalidateRgn(g_Wnd, rgn, 0); 01274 DeleteObject(rgn); 01275 } 01276 else 01277 { 01278 /* this is all in client coords */ 01279 rect.left = srcx - g_xscroll; 01280 rect.top = srcy - g_yscroll; 01281 rect.right = rect.left + cx; 01282 rect.bottom = rect.top + cy; 01283 clip_rect.left = g_clip_left - g_xscroll; 01284 clip_rect.top = g_clip_top - g_yscroll; 01285 clip_rect.right = g_clip_right - g_xscroll; 01286 clip_rect.bottom = g_clip_bottom - g_yscroll; 01287 if (IntersectRect(&draw_rect, &clip_rect, &g_wnd_clip)) 01288 { 01289 rgn = CreateRectRgn(0, 0, 0, 0); 01290 ScrollWindowEx(g_Wnd, x - srcx, y - srcy, &rect, &draw_rect, 01291 rgn, 0, SW_ERASE); 01292 InvalidateRgn(g_Wnd, rgn, 0); 01293 DeleteObject(rgn); 01294 } 01295 } 01296 } 01297 01298 /*****************************************************************************/ 01299 void 01300 mi_set_clip(int x, int y, int cx, int cy) 01301 { 01302 g_clip_left = x; 01303 g_clip_top = y; 01304 g_clip_right = g_clip_left + cx; 01305 g_clip_bottom = g_clip_top + cy; 01306 } 01307 01308 /*****************************************************************************/ 01309 void 01310 mi_reset_clip(void) 01311 { 01312 g_clip_left = 0; 01313 g_clip_top = 0; 01314 g_clip_right = g_clip_left + g_width; 01315 g_clip_bottom = g_clip_top + g_height; 01316 } 01317 01318 /*****************************************************************************/ 01319 void * 01320 mi_create_cursor(unsigned int x, unsigned int y, 01321 int width, int height, 01322 unsigned char * andmask, unsigned char * xormask) 01323 { 01324 HCURSOR hCur; 01325 01326 hCur = CreateCursor(g_Instance, x, y, width, height, andmask, xormask); 01327 if (hCur == 0) 01328 { 01329 hCur = LoadCursor(NULL, IDC_ARROW); 01330 } 01331 return hCur; 01332 } 01333 01334 /*****************************************************************************/ 01335 void 01336 mi_destroy_cursor(void * cursor) 01337 { 01338 if (g_cursor == cursor) 01339 { 01340 g_cursor = 0; 01341 } 01342 DestroyCursor(cursor); 01343 } 01344 01345 /*****************************************************************************/ 01346 void 01347 mi_set_cursor(void * cursor) 01348 { 01349 g_cursor = cursor; 01350 SetCursor(g_cursor); 01351 } 01352 01353 /*****************************************************************************/ 01354 void 01355 mi_set_null_cursor(void) 01356 { 01357 } 01358 Generated on Sat May 26 2012 04:16:07 for ReactOS by
1.7.6.1
|