int net_print_init(const char *rhost, unsigned short port) { int sk = -1; int wd = 0x12345678; if ( _net_print_socket < 0 ) { if (rhost==NULL){ rhost = DEFAULT_NET_PRINT_HOST; } if (port <= 0 ){ port = DEFAULT_NET_PRINT_PORT; } sk = clientsocket( rhost, port); if ( sk >= 0 ) { _net_print_socket = sk; net_print_string( __FILE__, __LINE__, "net_print_init() successful, socket=%d, testing for hi-low-byte using int 0x12345678:\n", _net_print_socket); net_print_binary( 'X', &wd, sizeof(wd)); } } return _net_print_socket; }
LRESULT CALLBACK WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam) { HDC hdc; WinProc_sub = hWnd; PAINTSTRUCT ps; HGDIOBJ hfDefault; RECT rt = { 100,100,1000,1000 }; static char str[256]; int xlnc, ylnc; int Lines; int nScroll; /* 하단 상태바 부분 */ int SBPart[4]; RECT prt; /* 플로팅 팝업 메뉴 부분 */ static COLORREF Color = RGB(255, 0, 0); HBRUSH hBrush; RECT crt; BOOLEAN delresult; switch (iMessage) { case WM_CREATE: AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT)hPopup, "즐겨찾기목록"); SetMenu(hWnd, hMenu); favorite_page_create(hWnd); EdittextBox = CreateWindowEx(WS_EX_CLIENTEDGE, "Edit", NULL, WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL, 115, 10, 300, 21, hWnd, (HMENU)IDC_MAIN_EDIT, NULL, NULL); hfDefault = GetStockObject(DEFAULT_GUI_FONT); SendMessage(EdittextBox, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0)); SendMessage(EdittextBox, WM_SETTEXT, NULL, (LPARAM)"주소입력창"); button = CreateWindow("BUTTON", "이동", WS_VISIBLE | WS_CHILD | WS_BORDER, 415, 10, 100, 20, hWnd, (HMENU)IDC_MAIN_BUTTON, NULL, NULL); SendMessage(button, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0)); /* 디렉토리 버튼 */ directory_button = CreateWindow("BUTTON", "방문기록보기", WS_VISIBLE | WS_CHILD | WS_BORDER, 520, 10, 100, 20, hWnd, (HMENU)IDC_VISITPAGE_BUTTON, NULL, NULL); SendMessage(directory_button, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0)); back_button = CreateWindow("BUTTON", "<-", WS_VISIBLE | WS_CHILD | WS_BORDER, 10, 10, 20, 20, hWnd, (HMENU)BACK_BUTTON, NULL, NULL); front_button = CreateWindow("BUTTON", "->",WS_VISIBLE | WS_CHILD | WS_BORDER, 30, 10, 20, 20, hWnd, (HMENU)FRONT_BUTTON, NULL, NULL); refresh_button = CreateWindow("BUTTON", "새로고침", WS_VISIBLE | WS_CHILD | WS_BORDER, 50, 10, 60, 20, hWnd, (HMENU)REFRESH_BUTTON, NULL, NULL); SendMessage(refresh_button, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0)); favorite_button = CreateWindow("BUTTON", "★", WS_VISIBLE | WS_CHILD | WS_BORDER, 622, 10, 20, 20, hWnd, (HMENU)FAVORITE_BUTTON, NULL, NULL); SendMessage(favorite_button, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0)); SetFocus(EdittextBox); OldEditProc = (WNDPROC)SetWindowLongPtr(EdittextBox, GWLP_WNDPROC, (LONG_PTR)SubEditProc); /* 스크롤바 부분 시작*/ xPos = 0; yPos = 0; xMax = 1000; yMax = 1000; SetScrollRange(hWnd, SB_VERT, 0, yMax, TRUE); SetScrollPos(hWnd, SB_VERT, 0, TRUE); SetScrollRange(hWnd, SB_HORZ, 0, xMax, TRUE); SetScrollPos(hWnd, SB_HORZ, 0, TRUE); SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &Lines, 0); WheelUnit = WHEEL_DELTA / Lines; /* 하단 상태바 부분 시작*/ InitCommonControls(); hState = CreateStatusWindow(WS_CHILD | WS_VISIBLE, "", hWnd, 0); SBPart[0] = 200; SBPart[1] = 500; SBPart[2] = 700; //남는 공간 나머지 할당 SBPart[3] = -1; SendMessage(hState, SB_SETPARTS, 4, (LPARAM)SBPart); SendMessage(hState, SB_SETTEXT, 0, (LPARAM) ""); //Progress bar SendMessage(hState, SB_SETTEXT, 1, (LPARAM) ""); //이미지 파일 이름 저장되는 공간 SendMessage(hState, SB_SETTEXT, 2, (LPARAM) ""); //다운로드파일 버튼 /* 프로그레스바 부분 시작 */ if (Pos) return 0; SendMessage(hState, SB_GETRECT, 0, (LPARAM)&prt); hProg = CreateWindow(PROGRESS_CLASS, NULL, WS_CHILD | PBS_SMOOTH | WS_VISIBLE, prt.left, prt.top, prt.right - prt.left, prt.bottom - prt.top, hState, NULL, g_hInst, NULL); Pos = 0; SendMessage(hProg, PBM_SETRANGE, 0, MAKELPARAM(0, 100)); SendMessage(hProg, PBM_SETPOS, Pos, 0); ShowWindow(hProg, SW_SHOW); //SendMessage(hState, SB_GETRECT, 2, (LPARAM)&prt); //두번째 빈칸 나중에 활용하기 break; //This is where we change the color of the static to blue. If you only want the cursor //to change to a hand when the mouse passes over you don't need this stuff. case WM_CTLCOLORSTATIC: SetTextColor((HDC)wParam, RGB(0, 0, 255)); SetBkMode((HDC)wParam, TRANSPARENT); return (LONG)GetStockObject(NULL_BRUSH); /* 하이퍼링크 부분*/ /* case WM_SETCURSOR: if ((HWND)wParam == hwndStatic) { if (colormsg == 1) return TRUE; SendMessage(hwndStatus, SB_SETTEXT, 0, (LONG) "Email : [email protected]"); SendMessage(hwndStatic, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 1); colormsg = 1; InvalidateRgn((HWND)hWnd, 0, 1); SetCursor(mycur); return TRUE; } //If not on the static, change the font back to normal. You don't have to worry //about the cursor, it will change back to the arrow automatically. I use the //'colormsg' flag so it doesn't continually set the font when the cursor is moving //around, because it causes it to flicker. If you only use the cursor change and //don't worry about the font change you don't have to worry. if (colormsg == 1) { colormsg = 0; SendMessage(hwndStatus, SB_SETTEXT, 0, 0); SendMessage(hwndStatic, WM_SETFONT, (WPARAM)GetStockObject(DEFAULT_GUI_FONT), 0); InvalidateRgn((HWND)hWnd, 0, 1); } break; */ /* 마우스 오른쪽 팝업 메뉴 */ case WM_CONTEXTMENU: hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_MENU1)); hPopup = GetSubMenu(hMenu, 0); TrackPopupMenu(hPopup, TPM_LEFTALIGN, (short)LOWORD(lParam), (short)HIWORD(lParam), 0, hWnd, NULL); DestroyMenu(hMenu); break; case WM_LBUTTONDOWN: //BitBlt(GetDC(hWnd), 0, 0, 1000, 1000, 0, 0, 0, WHITENESS); //그냥 화면을 하얗게만 할 뿐 뒤에 남아있음 //image_hyperlink_maker(WinProc_sub, "www.daum.net"); break; case WM_SIZE: SendMessage(hState, WM_SIZE, wParam, lParam); MoveWindow(hList, 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE);//디렉터리 탐색창 break; case WM_COMMAND: if ((HWND)lParam == hwndStatic) { //ShellExecute(Main_hWnd, "open", "www.naver.com", 0, 0, 0); cases = 2; //케이스 2번으로 하고 해야 계속해서 링크를 통해 이미지를 받아올 수 있음 clientsocket(textbox_buffer, PORT_NUM); //cases = 2이기 때문에 그냥 바로 요청하면 된다. //input_valid_check(textbox_buffer); // 주소체크하고 dns 실행할지말지 결정 InvalidateRect(Main_hWnd, NULL, WM_ERASEBKGND); UpdateWindow(Main_hWnd); } switch (LOWORD(wParam)) { case 50001: favorite_clicked(50001);break; case 50002: favorite_clicked(50002);break; case 50003: favorite_clicked(50003);break; case 50004: favorite_clicked(50004);break; case 50005: favorite_clicked(50005);break; case 50006: favorite_clicked(50006);break; case 50007: favorite_clicked(50007);break; case 50008: favorite_clicked(50008);break; case 50009: favorite_clicked(50009);break; case 50010: favorite_clicked(50010);break; case 50011: favorite_clicked(50011);break; case 50012: favorite_clicked(50012);break; case IDC_MAIN_BUTTON: // when button is clicked, this will happen: 버튼부분 SendMessage(EdittextBox, WM_GETTEXT, sizeof(textbox_buffer) / sizeof(textbox_buffer[0]), reinterpret_cast<LPARAM>(textbox_buffer)); image_file_name = NULL; Save_visit_page(textbox_buffer); input_valid_check(textbox_buffer); // 주소체크하고 dns 실행할지말지 결정 InvalidateRect(Main_hWnd, NULL, WM_ERASEBKGND); UpdateWindow(Main_hWnd); break; case IDC_VISITPAGE_BUTTON: printf("방문기록보기 버튼 클릭!\n"); Search_visit_page(); SetWindowText(Main_hWnd, "방문기록보기"); //ShellExecute(NULL, "open", "http://www.google.com", NULL, NULL, SW_SHOWNORMAL); InvalidateRect(Main_hWnd, NULL, WM_ERASEBKGND); UpdateWindow(Main_hWnd); break; case BACK_BUTTON: back_button_page(textbox_buffer); InvalidateRect(Main_hWnd, NULL, WM_ERASEBKGND); UpdateWindow(Main_hWnd); break; case FRONT_BUTTON: front_button_page(textbox_buffer); InvalidateRect(Main_hWnd, NULL, WM_ERASEBKGND); UpdateWindow(Main_hWnd); break; case REFRESH_BUTTON: //새로고침 if (textbox_buffer[0] == NULL) break; input_valid_check(textbox_buffer); // 주소체크하고 dns 실행할지말지 결정 InvalidateRect(Main_hWnd, NULL, WM_ERASEBKGND); UpdateWindow(Main_hWnd); break; case FAVORITE_BUTTON: //즐겨찾기 등록 favorite_page(textbox_buffer, strlen(textbox_buffer), hWnd); break; case ID_FILE_40001: //잘라내기 break; case ID_FILE_40003: //복사 break; case ID_FILE_40004: //삭제 delresult = DeleteFile("lenna.bmp"); //현재 미구현 디폴트상황 if(delresult == TRUE) MessageBox(NULL, "파일삭제 성공!", "파일삭제!", MB_ICONINFORMATION); else MessageBox(NULL, "파일이 없습니다!(이미 삭제되거나 없는 파일)", "파일삭제실패!", MB_ICONINFORMATION); break; case ID_FILE_RENAME: //이름바꾸기 break; case ID_FILE_PROPERTY: //속성 break; } break; /* case WM_CHAR: //사용자로부터 그냥 입력받을 때 동작 len = strlen(str); str[len] = (TCHAR)wParam; str[len + 1] = 0; InvalidateRect(hWnd, NULL, FALSE); break; */ case WM_PAINT: //사용자로부터 입력받은 것을 화면에 뿌려줌 hdc = BeginPaint(hWnd, &ps); DrawText(hdc, totalresult, -1, &rt, DT_CENTER | DT_WORDBREAK | DT_NOCLIP); Draw_Image(hdc, image_file_name, 300, 300); SendMessage(hState, SB_SETTEXT, 1, (LPARAM)image_file_name); //하단 상태바에 받은 이미지 파일 이름 출력 EndPaint(hWnd, &ps); SendMessage(hwndStatic, WM_ENABLE | WM_ERASEBKGND | WM_DESTROY, NULL, 1); break; case WM_MOUSEWHEEL: nScroll = 0; SumDelta += (short)HIWORD(wParam); while (abs(SumDelta) >= WheelUnit) { if (SumDelta > 0) { nScroll--; original_position--; SumDelta -= WheelUnit; } else { //스크롤바 내려갈때 nScroll++; original_position++; SumDelta += WheelUnit; } } while (nScroll != 0) { if (nScroll > 0) { SendMessage(hWnd, WM_VSCROLL, MAKELONG(SB_PAGEDOWN, 0), 0); nScroll--; } else { SendMessage(hWnd, WM_VSCROLL, MAKELONG(SB_PAGEUP, 0), 0); nScroll++; } } if (original_position == 0) { InvalidateRect(Main_hWnd, NULL, TRUE); UpdateWindow(Main_hWnd); } break; case WM_HSCROLL: //가로스크롤 xlnc = 0; switch (LOWORD(wParam)) { case SB_LINELEFT: xlnc = -1; break; case SB_LINERIGHT: xlnc = -20; break; case SB_PAGELEFT: xlnc = -20; break; case SB_PAGERIGHT: xlnc = 20; break; case SB_THUMBTRACK: xlnc = HIWORD(wParam) - xPos; break; default: InvalidateRect(Main_hWnd, NULL, TRUE); UpdateWindow(Main_hWnd); break; } //새로운 위치는 최소한 0 이상 if (xPos + xlnc < 0) xlnc = -xPos; //새로운 위치는 최대한 xMax 이하 if (xPos + xlnc > xMax) xlnc = xMax - xPos; //새로운 위치 계산 xPos = xPos + xlnc; //스크롤 시키고 썸 위치를 다시 계산한다. ScrollWindow(hWnd, -xlnc, 0, NULL, NULL); SetScrollPos(hWnd, SB_HORZ, xPos, TRUE); break; case WM_VSCROLL: //세로 스크롤 ylnc = 0; switch (LOWORD(wParam)) { case SB_LINEUP: ylnc = -1; break; case SB_LINEDOWN: ylnc = 1; break; case SB_PAGEUP: ylnc = -20; break; case SB_PAGEDOWN: ylnc = 20; break; case SB_THUMBTRACK: ylnc = HIWORD(wParam) - yPos; break; default: InvalidateRect(Main_hWnd, NULL, TRUE); UpdateWindow(Main_hWnd); break; } //새로운 위치는 최소한 0 이상 if (yPos + ylnc < 0) ylnc = -yPos; //새로운 위치는 최대한 yMax 이하 if (yPos + ylnc > yMax) ylnc = yMax - yPos; //새로운 위치 계산 yPos = yPos + ylnc; //스크롤 시키고 썸 위치를 다시 계산한다. ScrollWindow(hWnd, 0, -ylnc, NULL, NULL); SetScrollPos(hWnd, SB_VERT, yPos, TRUE); break; case WM_DESTROY: SetWindowLongPtr(EdittextBox, GWLP_WNDPROC, (LONG_PTR)OldEditProc); PostQuitMessage(0); break; default: return DefWindowProc(hWnd, iMessage, wParam, lParam); } }
LRESULT CALLBACK WndProc(HWND hWnd, UINT iMessage, WPARAM wParam, LPARAM lParam) { HDC hdc; WinProc_sub = hWnd; PAINTSTRUCT ps; HGDIOBJ hfDefault; RECT rt; RECT rt2; static wchar_t str[256]; int xlnc, ylnc; int Lines; int nScroll; /* 하단 상태바 부분 */ int SBPart[4]; RECT prt; SCROLLINFO si; /* 플로팅 팝업 메뉴 부분 */ static COLORREF Color = RGB(255, 0, 0); BOOLEAN delresult; switch (iMessage) { case WM_CREATE: AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT)hPopup, TEXT("즐겨찾기목록")); AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT)hPopup_setting, TEXT("설정")); AppendMenu(hPopup_setting, MF_STRING, 60000, TEXT("시작페이지설정")); SetMenu(hWnd, hMenu); favorite_page_create(hWnd); EdittextBox = CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("Edit"), NULL, WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL, 0, 30, 271, 21, hWnd, (HMENU)IDC_MAIN_EDIT, NULL, NULL); hfDefault = GetStockObject(DEFAULT_GUI_FONT); SendMessage(EdittextBox, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0)); SendMessage(EdittextBox, WM_SETTEXT, NULL, (LPARAM)TEXT("")); button = CreateWindow(TEXT("BUTTON"), TEXT("이동"), WS_VISIBLE | WS_CHILD | WS_BORDER, 270, 30, 70, 20, hWnd, (HMENU)IDC_MAIN_BUTTON, NULL, NULL); SendMessage(button, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0)); //방문기록 보기 visit_history_button = CreateWindow(TEXT("BUTTON"), TEXT("방문기록보기"), WS_VISIBLE | WS_CHILD | WS_BORDER, 150, 0, 100, 30, hWnd, (HMENU)IDC_VISITPAGE_BUTTON, NULL, NULL); SendMessage(visit_history_button, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0)); back_button = CreateWindow(TEXT("BUTTON"), TEXT("<-"), WS_VISIBLE | WS_CHILD | WS_BORDER, 50, 0, 20, 30, hWnd, (HMENU)BACK_BUTTON, NULL, NULL); front_button = CreateWindow(TEXT("BUTTON"), TEXT("->"),WS_VISIBLE | WS_CHILD | WS_BORDER, 70, 0, 20, 30, hWnd, (HMENU)FRONT_BUTTON, NULL, NULL); refresh_button = CreateWindow(TEXT("BUTTON"), TEXT("새로고침"), WS_VISIBLE | WS_CHILD | WS_BORDER,90, 0, 60, 30, hWnd, (HMENU)REFRESH_BUTTON, NULL, NULL); SendMessage(refresh_button, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0)); favorite_button = CreateWindow(TEXT("BUTTON"), TEXT("즐겨찾기등록"), WS_VISIBLE | WS_CHILD | WS_BORDER, 250, 0, 90, 30, hWnd, (HMENU)FAVORITE_BUTTON, NULL, NULL); SendMessage(favorite_button, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0)); home_button = CreateWindow(TEXT("BUTTON"), TEXT("홈으로"), WS_VISIBLE | WS_CHILD | WS_BORDER, 0, 0, 50, 30, hWnd, (HMENU)HOME_BUTTON, NULL, NULL); SendMessage(home_button, WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0)); SetFocus(EdittextBox); OldEditProc = (WNDPROC)SetWindowLongPtr(EdittextBox, GWLP_WNDPROC, (LONG_PTR)SubEditProc); /* 스크롤바 부분 시작*/ xPos = 0; yPos = 0; SetScrollRange(hWnd, SB_VERT, 0, yMax, TRUE); SetScrollPos(hWnd, SB_VERT, 0, TRUE); SetScrollRange(hWnd, SB_HORZ, 0, xMax, TRUE); SetScrollPos(hWnd, SB_HORZ, 0, TRUE); SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &Lines, 0); WheelUnit = WHEEL_DELTA / Lines; /* 하단 상태바 부분 시작*/ InitCommonControls(); hState = CreateStatusWindow(WS_CHILD | WS_VISIBLE, TEXT(""), hWnd, 0); SBPart[0] = 200; SBPart[1] = 500; SBPart[2] = 700; //남는 공간 나머지 할당 SBPart[3] = -1; SendMessage(hState, SB_SETPARTS, 4, (LPARAM)SBPart); SendMessage(hState, SB_SETTEXT, 0, (LPARAM) ""); //Progress bar SendMessage(hState, SB_SETTEXT, 1, (LPARAM) TEXT("")); //이미지 파일 이름 저장되는 공간 SendMessage(hState, SB_SETTEXT, 2, (LPARAM) TEXT("")); /* 프로그레스바 부분 시작 */ if (Pos) return 0; SendMessage(hState, SB_GETRECT, 0, (LPARAM)&prt); hProg = CreateWindow(PROGRESS_CLASS, NULL, WS_CHILD | PBS_SMOOTH | WS_VISIBLE, prt.left, prt.top, prt.right - prt.left, prt.bottom - prt.top, hState, NULL, g_hInst, NULL); Pos = 0; SendMessage(hProg, PBM_SETRANGE, 0, MAKELPARAM(0, 100)); SendMessage(hProg, PBM_SETPOS, Pos, 0); ShowWindow(hProg, SW_SHOW); load_Home(); //SendMessage(hState, SB_GETRECT, 2, (LPARAM)&prt); //두번째 빈칸 나중에 활용하기 break; //This is where we change the color of the static to blue. If you only want the cursor //to change to a hand when the mouse passes over you don't need this stuff. case WM_CTLCOLORSTATIC: SetTextColor((HDC)wParam, RGB(0, 0, 255)); SetBkMode((HDC)wParam, TRANSPARENT); return (LONG)GetStockObject(NULL_BRUSH); /* 마우스 오른쪽 팝업 메뉴 */ case WM_CONTEXTMENU: hMenu = LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_MENU1)); hMenu2 = LoadMenu(g_hInst, MAKEINTRESOURCE(IDR_MENU2)); hPopup = GetSubMenu(hMenu, 0); hPopup_setting = GetSubMenu(hMenu2, 0); TrackPopupMenu(hPopup, TPM_LEFTALIGN, (short)LOWORD(lParam), (short)HIWORD(lParam), 0, hWnd, NULL); TrackPopupMenu(hPopup_setting, TPM_LEFTALIGN, (short)LOWORD(lParam), (short)HIWORD(lParam), 0, hWnd, NULL); DestroyMenu(hMenu); DestroyMenu(hMenu2); break; case WM_LBUTTONDOWN: //test //printf("lbutton\n"); //BitBlt(GetDC(hWnd), 0, 0, 1000, 1000, 0, 0, 0, WHITENESS); //그냥 화면을 하얗게만 할 뿐 뒤에 남아있음 //image_hyperlink_maker(WinProc_sub, "www.daum.net"); break; case WM_SIZE: SendMessage(hState, WM_SIZE, wParam, lParam); /* 스크롤바 부분 */ break; case WM_COMMAND: switch (LOWORD(wParam)) { case 50001: favorite_clicked(50001);break; case 50002: favorite_clicked(50002);break; case 50003: favorite_clicked(50003);break; case 50004: favorite_clicked(50004);break; case 50005: favorite_clicked(50005);break; case 50006: favorite_clicked(50006);break; case 50007: favorite_clicked(50007);break; case 50008: favorite_clicked(50008);break; case 50009: favorite_clicked(50009);break; case 50010: favorite_clicked(50010);break; case 50011: favorite_clicked(50011);break; case 50012: favorite_clicked(50012);break; case 60000: DialogBox(g_hInst, MAKEINTRESOURCE(IDD_DIALOG2), hWnd, AboutDlgProc); break; case IDC_MAIN_BUTTON: // when button is clicked, this will happen: 버튼부분 SendMessage(EdittextBox, WM_GETTEXT, sizeof(textbox_buffer) / sizeof(textbox_buffer[0]), reinterpret_cast<LPARAM>(textbox_buffer)); if (textbox_buffer[0] == '\0') { break; } if(input_valid_check(textbox_buffer) == 1) // 주소체크하고 dns 실행할지말지 결정 Save_visit_page(textbox_buffer); InvalidateRect(Main_hWnd, NULL, WM_ERASEBKGND); UpdateWindow(Main_hWnd); break; case IDC_VISITPAGE_BUTTON: wcout << TEXT("방문기록보기 버튼 클릭!\n") << endl; if (image_exist == 1) { image_exist = 0; } if (hwndStatic != NULL) { DestroyWindow(hwndStatic); temp_port2 = 0; hypertext = TEXT(""); } Search_visit_page(); SetWindowText(Main_hWnd, TEXT("방문기록보기")); InvalidateRect(Main_hWnd, NULL, WM_ERASEBKGND); UpdateWindow(Main_hWnd); break; case BACK_BUTTON: back_button_page(textbox_buffer); InvalidateRect(Main_hWnd, NULL, WM_ERASEBKGND); UpdateWindow(Main_hWnd); break; case FRONT_BUTTON: front_button_page(textbox_buffer); InvalidateRect(Main_hWnd, NULL, WM_ERASEBKGND); UpdateWindow(Main_hWnd); break; case REFRESH_BUTTON: //새로고침 if (textbox_buffer[0] == '\0') break; input_valid_check(textbox_buffer); // 주소체크하고 dns 실행할지말지 결정 InvalidateRect(Main_hWnd, NULL, WM_ERASEBKGND); UpdateWindow(Main_hWnd); break; case HOME_BUTTON: load_Home(); break; case FAVORITE_BUTTON: //즐겨찾기 등록 favorite_page(textbox_buffer, wcslen(textbox_buffer), hWnd); break; case ID_FILE_40001: //잘라내기 break; case ID_FILE_40003: //복사 break; case ID_FILE_40004: //삭제 delresult = DeleteFile(image_file_name); //현재 미구현 디폴트상황 if(delresult == TRUE) MessageBox(NULL, TEXT("파일삭제 성공!"), TEXT("파일삭제!"), MB_ICONINFORMATION); else MessageBox(NULL, TEXT("파일이 없습니다!(이미 삭제되거나 없는 파일)"), TEXT("파일삭제실패!"), MB_ICONINFORMATION); break; case ID_FILE_RENAME: //이름바꾸기 break; case ID_FILE_PROPERTY: //속성 break; } //더블 체크드 하자 if (((HWND)lParam == hwndStatic) && (is_hyper_clicked_possible == 1)) { cases = 2; //케이스 2번으로 하고 해야 계속해서 링크를 통해 이미지를 받아올 수 있음 //여기서 케이스2로 돌리는구나. clientsocket(temp_addr2, temp_port2); //cases = 2이기 때문에 그냥 바로 요청하면 된다. InvalidateRect(Main_hWnd, NULL, TRUE); UpdateWindow(Main_hWnd); } else if (((HWND)lParam == hwndStatic) && (is_hyper_clicked_possible == 2)) { cases = 0; input_valid_check(textbox_buffer); InvalidateRect(Main_hWnd, NULL, TRUE); UpdateWindow(Main_hWnd); } break; case WM_PAINT: //사용자로부터 입력받은 것을 화면에 뿌려줌 hdc = BeginPaint(hWnd, &ps); si.cbSize = sizeof(SCROLLINFO); si.fMask = SIF_POS; GetScrollInfo(hWnd, SB_VERT, &si); rt2 = { 10-xPos,100-yPos,300,100 }; DrawText(hdc, hypertext, -1, &rt2, DT_WORDBREAK | DT_NOCLIP); rt = { 100-xPos,150-yPos,1024,768 }; //for문 안돌려도 된다. DrawText(hdc, wow, -1, &rt, DT_WORDBREAK | DT_NOCLIP | DT_EXTERNALLEADING); if(image_exist == 1) //이미지가 있을 때만 보여준다. Draw_Image(hdc, image_file_name, 100 - xPos+200, 100 - yPos+200); SendMessage(hState, SB_SETTEXT, 1, (LPARAM)image_file_name); //하단 상태바에 받은 이미지 파일 이름 출력 EndPaint(hWnd, &ps); break; case WM_MOUSEWHEEL: nScroll = 0; SumDelta += (short)HIWORD(wParam); while (abs(SumDelta) >= WheelUnit) { if (SumDelta > 0) { nScroll--; SumDelta -= WheelUnit; } else { //스크롤바 내려갈때 nScroll++; SumDelta += WheelUnit; } } while (nScroll != 0) { if (nScroll > 0) { SendMessage(hWnd, WM_VSCROLL, MAKELONG(SB_PAGEDOWN, 0), 0); nScroll--; } else { SendMessage(hWnd, WM_VSCROLL, MAKELONG(SB_PAGEUP, 0), 0); nScroll++; } } break; case WM_HSCROLL: //가로스크롤 xlnc = 0; switch (LOWORD(wParam)) { case SB_LINELEFT: xlnc = -1; break; case SB_LINERIGHT: xlnc = 1; break; case SB_PAGELEFT: xlnc = -20; break; case SB_PAGERIGHT: xlnc = 20; break; case SB_THUMBTRACK: xlnc = HIWORD(wParam) - xPos; break; default: break; } //새로운 위치는 최소한 0 이상 if (xPos + xlnc < 0) xlnc = -xPos; //새로운 위치는 최대한 xMax 이하 if (xPos + xlnc > xMax) xlnc = xMax - xPos; //새로운 위치 계산 xPos = xPos + xlnc; //스크롤 시키고 썸 위치를 다시 계산한다. ScrollWindow(hWnd, -xlnc, 0, NULL, NULL); SetScrollPos(hWnd, SB_HORZ, xPos, TRUE); break; case WM_VSCROLL: //세로 스크롤 ylnc = 0; switch (LOWORD(wParam)) { case SB_LINEUP: ylnc = -1; break; case SB_LINEDOWN: ylnc = 1; break; case SB_PAGEUP: ylnc = -20; break; case SB_PAGEDOWN: ylnc = 20; break; case SB_THUMBTRACK: ylnc = HIWORD(wParam) - yPos; break; default: break; } //새로운 위치는 최소한 0 이상 if (yPos + ylnc < 0) ylnc = -yPos; //새로운 위치는 최대한 yMax 이하 if (yPos + ylnc > yMax) ylnc = yMax - yPos; //새로운 위치 계산 yPos = yPos + ylnc; //스크롤 시키고 썸 위치를 다시 계산한다. ScrollWindow(hWnd, 0, -ylnc, NULL, NULL); SetScrollPos(hWnd, SB_VERT, yPos, TRUE); MoveWindow(hState, xPos, yPos, LOWORD(lParam), HIWORD(lParam), TRUE); //하단 상태바 이동 break; case WM_DESTROY: SetWindowLongPtr(EdittextBox, GWLP_WNDPROC, (LONG_PTR)OldEditProc); PostQuitMessage(0); break; default: return DefWindowProc(hWnd, iMessage, wParam, lParam); } }