Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,971 questions

51,913 answers

573 users

How to print the screen resolution with MessageBoxW and _vsnwprintf_s in C Win32 API

1 Answer

0 votes
#include <windows.h>
#include <stdio.h> 

int CDECL MsgBoxPrintf(wchar_t *szCaption,const wchar_t *szFormat, ...)
{
    wchar_t szBuffer[1024];
    va_list pArgsList;
    va_start(pArgsList, szFormat);
  
    _vsnwprintf_s(szBuffer, sizeof(szBuffer)/sizeof(wchar_t), 1024-1, szFormat, pArgsList);
    
	va_end(pArgsList);
        
	return MessageBoxW(0, szBuffer, szCaption, 0);
}

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow)
{
    int cxScreen, cyScreen;

    cxScreen = GetSystemMetrics(SM_CXSCREEN);
    cyScreen = GetSystemMetrics(SM_CYSCREEN);
    MsgBoxPrintf(L"My Screen Size",L"The Screen is: %i Pixels Width and %i Pixels Height.
                 \n\nScreen Resolution is: %ix%i", cxScreen, cyScreen, cxScreen, cyScreen);


    return(0);
}


answered Feb 1, 2015 by avibootz
...