Technical window: Technical technical foundation capplication (. cpp) (ii)

Source: Internet
Author: User

Technical window: Technical technical foundation type capplication (. cpp), available

//////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////

/// // Capplication. cpp ///////

//////////////////////////////////////// //////////////////////////////////////// //////////////////////////////////////// //////////////////////////////

# Include <windows. h>
# Include "capplication. H"

Capplication: capplication (INT bfullscr, int scrw, int scrh)
{
M_bfullscreen = bfullscr;

// Full screen mode
If (bfullscr)
{
If (scrw> = 1024)
{
Screenw = 1024;
Screenh = 768;
}
Else if (scrw >=800)
{
Screenw = 800;
Screenh = 600;
}
Else
{
Screenw = 640;
Screenh = 480;
}
}
// Window mode
Else
{
Screenw = scrw;
Screenh = scrh;
}


Bactive = false;
Hwnd = NULL;
Show_mouse_cursor = true;
Change_size_able = false;
Clientbkcolor = white_brush;

Hicon = loadicon (null, makeintresource (idi_application ));
Hcursor = loadcursor (null, makeintresource (idc_arrow ));
Hmenu = NULL;
}

// Create a letter number
Capplication: capplication (void)
{
M_bfullscreen = false;
Screenw = 640;
Screenh = 480;
Bactive = false;
Hwnd = NULL;
Show_mouse_cursor = true;
Change_size_able = true;
Clientbkcolor = white_brush;

Hicon = loadicon (null, makeintresource (idi_application ));
Hcursor = loadcursor (null, makeintresource (idc_arrow ));
Hmenu = NULL;
}

//
Hwnd capplication: createwin (wndproc winproc,
Hinstance,
Tchar * windowname,
DWORD winstyle)
{
Wndclass WC;

WC. hinstance = hinstance;
WC. lpszclassname = windowname;
// WC. lpfnwndproc = (wndproc) wndproc;
WC. lpfnwndproc = winproc;

WC. Style = cs_hredraw | cs_vredraw;
WC. hicon = hicon;
WC. hcursor = hcursor;
WC. lpszmenuname = NULL;
WC. cbclsextra = 0;
WC. cbwndextra = 0;
WC. hbrbackground = (hbrush) getstockobject (clientbkcolor );
 
If (! Registerclass (& WC ))
{
MessageBox (null, "invalid Variable Window Type outputs! "," Zookeeper ", mb_ OK );
Return false;
}

// Full screen mode
If (m_bfullscreen = true)
{
Hwnd = createwindow (windowname,
Windowname,
Ws_popup,
0,
0,
Getsystemmetrics (sm_cxscreen ),
Getsystemmetrics (sm_cyscreen ),
Null,
Hmenu,
Hinstance,
Null );
If (! Hwnd)
{
MessageBox (null, "the producer creates a window to exit the producer! "," Zookeeper ", mb_ OK );
Return false;
}
}
// Window mode
Else
{
Hwnd = createdomainwex (0,
Windowname,
Windowname,
Winstyle,
Cw_usedefault,
Cw_usedefault,
Cw_usedefault,
Cw_usedefault,
Null,
Hmenu,
Hinstance,
Null );
If (! Hwnd)
{
MessageBox (null, "the producer creates a window to exit the producer! "," Zookeeper ", mb_ OK );
Return false;
}

// Resize the screen
Int win_w = getsystemmetrics (sm_cxscreen );
Int win_h = getsystemmetrics (sm_cyscreen );

// The center of the computing window in the upper left corner
Int X1 = (win_w-screenw)/2;
Int Y1 = (win_h-screenh)/2;
// The Position of the entire window in the upper limit
Setwindowpos (hwnd,
Hwnd_notopmost,
X1,
Y1,
Screenw,
Screenh,
Swp_hidewindow );

// Retrieve the location in the upper left corner of the screen corresponding to the customer's Region
Getclientrect (hwnd, & rectwin );
Clienttoscreen (hwnd, (lppoint) & rectwin );
Clienttoscreen (hwnd, (lppoint) & rectwin + 1 );
}
Showwindow (hwnd, sw_normal );
Updatewindow (hwnd );

Return hwnd;
}

// Message handling in the Main Window
Lresult capplication: msgproc (hwnd,
Uint umsg,
Wparam,
Lparam)
{
Switch (umsg)
{
// Activate zookeeper message processing in the window
Case wm_activateapp:
Bactive = (bool) wparam;
Break;

// Indicates the mobile processing of a mouse.
Case wm_setcursor:
If (! Show_mouse_cursor)
{
Setcursor (null );
Return true;
}
Break;

// Change the window size to Message Processing
Case wm_size:
If (! Change_size_able)
{
If (m_bfullscreen = 0)
{
// Retrieve the screen position of the window's passenger area
Getclientrect (hwnd, & rectwin );
Clienttoscreen (hwnd, (lppoint) & rectwin );
Clienttoscreen (hwnd, (lppoint) & rectwin + 1 );
}
}
Break;

// Message Handling for window location change
Case wm_move:
If (m_bfullscreen = 0)
{
// Retrieve the screen position of the window's passenger area
Getclientrect (hwnd, & rectwin );
Clienttoscreen (hwnd, (lppoint) & rectwin );
Clienttoscreen (hwnd, (lppoint) & rectwin + 1 );
}
Break;

// Maximum and minimum window size Message Processing
Case wm_getminmaxinfo:
// The window size cannot be changed.
If (! Change_size_able)
{
Pminmaxinfo PMM = (pminmaxinfo) lparam;

// Set the orientation, orientation, and topic height of the orientation box.
Int framew = getsystemmetrics (sm_cxsizeframe );
Int frameh = getsystemmetrics (sm_cysizeframe );
Int caph = getsystemmetrics (sm_cycaption );

// Change the minimum size of the window to the previous value.
PMM-> ptmintracksize. x = screenw + framew * 2;
PMM-> ptmintracksize. Y = screenh + frameh * 2 + caph;

// Change the maximum size of the window to the same value as the minimum size.
PMM-> ptmaxtracksize. x = PMM-> ptmintracksize. X;
PMM-> ptmaxtracksize. Y = PMM-> ptmintracksize. Y;
}
Else
{
Pminmaxinfo PMM = (pminmaxinfo) lparam;

// Limit the minimum size that the window can be changed
PMM-> ptmintracksize. x = 100;
PMM-> ptmintracksize. Y = 150;
}
Break;

// Message handling in the parameter window
Case wm_close:
Destroywindow (hwnd );
Break;

// Handle messages in the zookeeper window
Case wm_destroy:
Postquitmessage (0 );
Break;
}

// MMO Message Handling
Return defwindowproc (hwnd, umsg, wparam, lparam );
}

// Mechanism of message-based message sharing
Int capplication: rundefault (void)
{
MSG;
MSG. Message = wm_null;

While (msg. message! = Wm_quit)
{
If (getmessage (& MSG, null, 0, 0 ))
{
Translatemessage (& MSG );
Dispatchmessage (& MSG );
}
}

Return (INT) msg. wparam;
}

//////////////////////////////////////// ////////////// //////////////////////////////////////// ////////////////////////

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.