A função trocar é responsável por inverter os valores de "a" e "b"

main.html
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <tchar.h>
#include "resource.h"

void trocar(int *, int *);

char txt[] = {"Trocar"};

TCHAR szAppName[] = TEXT("RECURSOS");

HFONT hFonte;

static HWND btn, edit1, edit2, edit3, edit4;

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wP, LPARAM lP) {
    switch(msg) {
        case WM_CREATE:
            hFonte=CreateFont(28,0,0,0,0,FALSE,0,0,0,0,0,0,0,"Arial");
            edit1 = CreateWindow(
                TEXT("edit"),TEXT(""),WS_VISIBLE|WS_CHILD|DT_CENTER,
                10, 80, 80, 30,
                hwnd, NULL, NULL, NULL
            );
            edit2 = CreateWindow(
                TEXT("edit"),TEXT(""),WS_VISIBLE|WS_CHILD|DT_CENTER,
                120, 80, 80, 30,
                hwnd, NULL, NULL, NULL
            );
            btn = CreateWindow(
                TEXT("button"), TEXT("Trocar"), WS_VISIBLE | WS_CHILD,
                230, 80, 120, 30,
                hwnd, (HMENU) IBTN, NULL, NULL
            );
            edit3 = CreateWindow(
                TEXT("edit"),TEXT(""),WS_VISIBLE|WS_CHILD|DT_CENTER,
                380, 80, 80, 30,
                hwnd, NULL, NULL, NULL
            );
            edit4 = CreateWindow(
                TEXT("edit"),TEXT(""),WS_VISIBLE|WS_CHILD|DT_CENTER,
                490, 80, 80, 30,
                hwnd, NULL, NULL, NULL
            );
            SendMessage(btn, WM_SETFONT, (WPARAM) hFonte, TRUE);
            SendMessage(edit1, WM_SETFONT, (WPARAM) hFonte, TRUE);
            SendMessage(edit2, WM_SETFONT, (WPARAM) hFonte, TRUE);
            SendMessage(edit3, WM_SETFONT, (WPARAM) hFonte, TRUE);
            SendMessage(edit4, WM_SETFONT, (WPARAM) hFonte, TRUE);
            return 0;
        case WM_COMMAND:
            if(LOWORD(wP)==IDM_A1) {
                int cxScreen, cyScreen;
                cxScreen = GetSystemMetrics(0);
                cyScreen = GetSystemMetrics(1);
                char tela[20];
                wsprintf(
                    tela,
                    "Vertical: %d Horiontal: %d",
                    cxScreen,
                    cyScreen
                );
            	MessageBox(
                    NULL,
                    tela,
                    "Medidas do Monitor!",
                    MB_OK
                );
            }
            if(LOWORD(wP)==IDM_A2) {
            	MessageBox(
                    NULL,
                    "O aplicativo será fechado!",
                    "Aviso!",
                    MB_OK
                );
                exit(0);
            }
            if(LOWORD(wP)==IDM_A3) {
            	MessageBox(
                    NULL,
                    __TIME__,
                    "Hora:",
                    MB_OK
                );
            }
            if(LOWORD(wP)==IBTN) {
            	int x = GetWindowTextLength(edit1)+1;
            	int y = GetWindowTextLength(edit2)+1;
            	static char a[50], b[50];
                GetWindowText(edit1, a, x);
                GetWindowText(edit2, b, y);
                int n1 = atoi(a), n2 = atoi(b);
                trocar(&a, &b);
                SetWindowText(edit3, a);
                SetWindowText(edit4, b);
            }
            return 0;
        case WM_DESTROY: {
            PostQuitMessage(0);
            break;
        }
		
        default:
            return DefWindowProc(hwnd, msg, wP, lP);
    }
    return 0;
}

int WINAPI WinMain(HINSTANCE hI, HINSTANCE hPI, LPSTR szCL, int iCS) {
    WNDCLASS wc;
    HWND     hwnd;
    MSG      msg;

    wc.style       = CS_HREDRAW | CS_VREDRAW;
    wc.lpfnWndProc = WndProc;
    wc.cbClsExtra  = 0;
    wc.cbWndExtra  = 0;
    wc.hInstance   = hI;
    wc.hIcon       = LoadIcon(hI, ICONE);
    wc.hCursor     = LoadCursor(NULL, IDC_ARROW);
    wc.hbrBackground = GetSysColorBrush(COLOR_MENUHILIGHT);
    wc.lpszMenuName  = szAppName;
    wc.lpszClassName = szAppName;

    if(!RegisterClass(&wc)) {
        MessageBox(
            NULL,
            "Window Registration Failed!",
            "Error!",
            MB_ICONEXCLAMATION | MB_OK
        );
        return 0;
    }

    hwnd = CreateWindow(
        szAppName, txt, WS_VISIBLE | WS_OVERLAPPEDWINDOW,
        CW_USEDEFAULT, CW_USEDEFAULT, 600, 250,
        NULL, NULL, hI, NULL
    );

    ShowWindow(hwnd, iCS);
    UpdateWindow(hwnd);

    while(GetMessage(&msg, NULL, 0, 0) > 0) {
        TranslateMessage(&msg);
        DispatchMessage(&msg); /* Send it to WndProc */
    }
    return msg.wParam;
}

void trocar(int *p, int *q) {
    int x;
    x = *p;
    *p = *q;
    *q = x;
}

Comentários