Programming Windows Programming Guide-> Chapter 2 example Program

Source: Internet
Author: User

/*_##################################### #######################################
_##
### Programming Windows Programming Design Guide-> Chapter 2 example Program
_ ## Author: xwlee
_ ## Time: 2007.06.01
### Chang'an University
_ ## Development condition: win2003 SERVER + vc6.0
_##
_ ## Program 2-1 scrnsize
_ ## Scrnsize. c file
### The scrnsize program shown in program 2-1 shows how to implement the messageboxprintf function,
_ ## This function has many parameters and can orchestrate their formats like printf.
_##
_##
_##
_ ## Scrnsize. c -- displays screen size in a message box
_ ## (C) Charles Petzold, 1998
_##
_####################################### ###################################*/

# Include <windows. h>
# Include <tchar. h>
# Include <stdio. h>

 
// This Is A Variable Parameter Function
Int cdecl messageboxprintf (tchar * szcaption, tchar * szformat ,...)

{

Tchar szbuffer [1024];
Va_list parglist;

// About va_list, va_start, and va_end, the macro used to define variable parameters

// The va_start macro (defined in stdarg. h) is usually equivalent:
// Parglist = (char *) & szformat + sizeof (szformat );
Va_start (parglist, szformat); // locate the address of the first Variable Parameter

// The last argument to wvsprintf points to the arguments
_ Vsntprintf (szbuffer, sizeof (szbuffer)/sizeof (tchar ),
Szformat, parglist );

// The va_end macro just zeroes out parglist for no good reason
Va_end (parglist );

Return MessageBox (null, szbuffer, szcaption, 0 );
}

 

Int winapi winmain (hinstance, hinstance hprevinstance,

Pstr szcmdline, int icmdshow)

{

Int cxscreen, cyscreen;

Cxscreen = getsystemmetrics (sm_cxscreen); // call the system function

Cyscreen = getsystemmetrics (sm_cyscreen); // call the system function

 

Messageboxprintf (text ("scrnsize "),

Text ("the screen is % I pixels wide by % I pixels High ."),

Cxscreen, cyscreen );

Messageboxprintf (text ("Chang 'an University, haha "),

Text ("the current screen size is: % I pixel width, % I pixel height. "),

Cxscreen, cyscreen );

Return 0;

}

 

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.