GUI Socket Application

Slides:



Advertisements
Similar presentations
Prof. Muhammad Saeed. Procedure-Driven Programming Event-Driven Programming Events Messages Event Handlers GUI Windows and Multitasking Queues ( System.
Advertisements

QT – Introduction C++ GUI Programming with Qt 4 Blanchette and Summerfield, Ch. 1 Miller, 2004.
Introduction to Windows Programming. First Windows Program This program simply displays a blank window. The following code is the minimum necessary to.
IN-LAB # 1 - GETTING STARTED - BUT FIRST: 1.Project ideas - watch the scope!!! 2.Check accounts 3. Either myself or the TA need to check you off BEFORE.
Simple Gui in C++. Project Selecting So Far Registering the window class Creating the window.
First Windows Program Hello Windows. 2 HELLOWIN.C #include LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ; int WINAPI WinMain (HINSTANCE hInstance,
Intro to Windows Programming Basic Ideas. Program Entry Point Int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
GVE, Hallym University, Song, Chang Geun, Ph.D. 컴퓨터 그래픽스 응용 한림대학교 컴퓨터공학부 송 창근.
Further Programming for 3D applications CE Introduction to Further Programming for 3D application Bob Hobbs Faculty of Computing, Engineering and.
6. 마우스.
Prepared by Fareeha Lecturer DCS IIUI 1 Windows API.
Overview of Previous Lesson(s) Over View  Visual C++ provides us with 3 basic ways of creating an interactive Windows application  Using the Windows.
Chapter 1: Hello, MFC Windows Programming Model Department of Digital Contents Sang Il Park.
Chapter 1: Hello, MFC Your first MFC Application Department of Digital Contents Sang Il Park.
Lecture Two Event Handling Keyboard and Mouse Input.
QT – Introduction C++ GUI Programming with Qt 4
Server Core is the preferred deployment configuration.
CSE3AGT Paul Taylor Stupid Conventions! l = Long p = Pointer h = handle g = global wnd = Windows WM = Windows Message d3d = Direct3D hr = HRESULT.
Winsock Programming Blocking and Asynchronous Sockets for Windows.
Further games and graphics concepts COSE50581 Introduction to Module and Recap Bob Hobbs Faculty of Computing, Engineering and Technology Staffordshire.
BZUPAGES.COM Visual Programming Lecture – 2 Miss. SADAF MAJEED SIAL Computer Science Department Bahauddin Zakariya University Multan.
Direct3D Workshop November 17, 2005 Workshop by Geoff Cagle Presented by Players 2 Professionals.
GAM666 – Introduction To Game Programming You must use special libraries (aka APIs – application programming interfaces) to make something other than a.
GUI-Based Programming ECE 417/617: Elements of Software Engineering Stan Birchfield Clemson University.
Dialog boxes Modal and modeless dialog boxes Displaying about dialog box: case WM_COMMAND : switch (LOWORD (wParam)) { case IDM_APP_ABOUT : DialogBox (hInstance,
Quanta Confidential QUANTA WBU Study Report 1 昭正 2008/08/01.
Creating a DirectX Project A DirectPLay Chat Program.
1 Programming and Software Engineering. 2 Software Development We can define two main classes of software: User-written software solve a particular problem,
The WM_NCHITTEST Message  This is an internal message used by Windows for generating all the other mouse messages.  Though it almost never needs to be.
Menus  Menus is a feature which is common to almost every windows applications. It is the one of the most common user interface elements around.  Windows.
9. 메뉴와 기타 자원. 1. 자원 – 아이콘, 커서, 메뉴, 대화상자는 모두 Windows 의 자원이다. – 자원은 데이터로 생각할 수 있으며, 프로그램의 EXE 파일에 저장된 다. – 실행 가능한 프로그램의 데이터 영역에는 존재하지 않는다. 자원은 프로그램 소스코드에.
Introduction to OpenGL
Microsoft Foundation Classes
Learning Programming Windows API Morpheus Feb-28, 2008.
Sockets A popular API for client-server interaction.
Our good old first Win32 programme of lecture 8 #include int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
W indows Programming Lecture 08. Brief History of Win Windows is announced 1984 Work begins on Word for Windows 1.0 November 1985: Windows 1.0.
Lecture 8: Discussion of papers OpenGL programming Lecturer: Simon Winberg Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
Windows Programming Lecture 14. WM_PAINT message Whenever an application receives the WM_PAINT message, whether the entire window needs repainting? WM_PAINT.
Visual Info Processing Programming Guide
Anatomy and Defense Against Keyloggers
Topics Graphical User Interfaces Using the tkinter Module
Windows Programming Lecture 10.
Chapter Topics 15.1 Graphical User Interfaces
Visual Programming Lecture 1 & 2
Mobile Operating System
Windows Programming Lecture 09.
Window.
Building a Win32API Application
18 & 19.
Windows Programming Model
Event Driven Programming
Windows Programming using Dev C++
Dialogo langai Benas Ragauskas, PS m.
Windows Development Dynadata Copyright, 2014 © DynaData S.A. 1/10.
The program in traditional OS
Windows Programming Lecture 12
28.
GTK + Programming.
Windows Programming Lecture 13
CS 1253 Visual Programming Unit I Windows Environment
Windows Programming Lecture 15
Chapter 15: GUI Applications & Event-Driven Programming
21-22.
Why Threads Are A Bad Idea (for most purposes)
Windows Development Dynadata Copyright, 2014 © DynaData S.A. 1/10.
Why Threads Are A Bad Idea (for most purposes)
Graphics Laboratory Korea University
Why Threads Are A Bad Idea (for most purposes)
OpenGL Programming – Day 1
Presentation transcript:

GUI Socket Application Chapter 08. GUI Socket Application

Understanding the structure and principle of Windows GUI applications Goal Understanding the structure and principle of Windows GUI applications Learning how to make Windows based socket applications Understanding the structure and principle of dialog based applications Learning how to make dialog based socket applications

Windows GUI Application (1/8) Features of Windows GUI application Providing easy graphical user interface using various API (Application Programming Interface) Operating by using message-driven architecture Terms API Core library provided by Windows OS Event / message how windows communicate

Windows GUI Application (2/8) Message-driven architecture ① System Message queue event Application message queue #1 message queue #2 message queue #3 ... processing waiting

Event/Message loop

Windows GUI Application (3/8) GUI application code Message processing depending on the window procedure written by programmer Unprocessed message is processed by window OS Terms message handler Message handling code window procedure A set of message handler

Windows GUI Application (4/8) Code example #include <windows.h> // ① LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); // ② int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR lpCmdLine, int nCmdShow) // ③ { // window class registration ④ WNDCLASS wndclass; wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 0; wndclass.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH); wndclass.hCursor = LoadCursor(NULL, IDC_ARROW); wndclass.hIcon = LoadIcon(NULL, IDI_APPLICATION); wndclass.hInstance = hInstance; wndclass.lpszClassName = "MyWindowClass"; wndclass.lpszMenuName = NULL; wndclass.style = CS_HREDRAW | CS_VREDRAW; wndclass.lpfnWndProc = (WNDPROC)WndProc; if(!RegisterClass(&wndclass)) return -1;

Windows GUI Application (5/8) Code example (cont’d) // Window creation ⑤ HWND hWnd = CreateWindow("MyWindowClass", "WinApp", WS_OVERLAPPEDWINDOW, 0, 0, 600, 300, NULL, (HMENU)NULL, hInstance, NULL); if(hWnd == NULL) return -1; ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); // message loop ⑥ MSG msg; while(GetMessage(&msg, 0, 0, 0) > 0){ TranslateMessage(&msg); DispatchMessage(&msg); } return msg.wParam;

Windows GUI Application (6/8) Code example (cont’d) // window procedure ⑦ LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch(uMsg){ case WM_CREATE: return 0; case WM_SIZE: case WM_DESTROY: PostQuitMessage(0); } return DefWindowProc(hWnd, uMsg, wParam, lParam);

Windows GUI Application (7/8) Message-driven architecture ② System Message queue event Application Message queue #1 Message queue #2 Message queue #3 ... application #1 Message loop Message handler #1 Message handler #2 Message handler #3 ••• DefWindowProc() Window procedure

Windows GUI Application (8/8) control A kind of window provided by windows OS Input/output and display information WinApp.cpp

windows based socket application Structure GUITCPServer.cpp Thread 1 Message loop Message handler #1 Message handler #2 Message handler #3 ••• DefWindowProc() Window procedure thread2 thread3 ... Thread n Window message handling Socket comm. and data processing

Dialog based application (1/4) A kind of window containing various control A part of application Processing user input and output

Dialog based application (2/4) Independent dialog based application

Dialog based application (3/4) Code example #include <windows.h> #include "resource.h" // ① BOOL CALLBACK DlgProc(HWND, UINT, WPARAM, LPARAM); // ② int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR lpCmdLine, int nCmdShow) { DialogBox(hInstance, MAKEINTRESOURCE(IDD_DIALOG1), NULL, DlgProc); // ③ return 0; } BOOL CALLBACK DlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) // ④

Dialog based application (4/4) Code example (cont’d) DlgApp.cpp switch(uMsg){ case WM_INITDIALOG: // ⑤ return TRUE; case WM_COMMAND: // ⑥ switch(LOWORD(wParam)){ case IDOK: EndDialog(hDlg, 0); // ⑦ case IDCANCEL: EndDialog(hDlg, 0); } return FALSE;

Dialog based socket application (1/2) Structure Same as general GUI socket application dialog message handling Socket comm. and data processing Thread 1 thread2 thread3 ... Thread n Message loop Window procedure Message handler #1 Message handler #2 Message handler #3 •••

Dialog based socket application (2/2) Thread synchronization is needed GUITCPclient.cpp Application buffer ② ① ③ ④ ⑤ network thread 1 thread 2