C 上下控制比巴迪高

C 上下控制比巴迪高,c,winapi,C,Winapi,纯C,winapi应用程序 在从资源脚本创建的对话框上,它非常适合,但使用CreateWindowEx创建时,上下控件比好友窗口(编辑控件)两侧高一个像素。 这没什么大不了的,但很烦人。我用尽了我能想到的一切办法,但都没能把它修好,非常感谢你的帮助 代码如下: #include <Windows.h> #include <Commctrl.h> #include <stdio.h> #define print(...) sprintf(dbg, __VA_

纯C,winapi应用程序

在从资源脚本创建的对话框上,它非常适合,但使用CreateWindowEx创建时,上下控件比好友窗口(编辑控件)两侧高一个像素。 这没什么大不了的,但很烦人。我用尽了我能想到的一切办法,但都没能把它修好,非常感谢你的帮助

代码如下:

#include <Windows.h>
#include <Commctrl.h>
#include <stdio.h>

#define print(...)  sprintf(dbg, __VA_ARGS__);\
                    WriteConsoleA(h_con_out, dbg, strlen(dbg), NULL, NULL)

TCHAR *app_name = TEXT("ud");
HANDLE h_con_out;
char dbg[80];

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR szCmdLine, int iCmdShow){
    HWND hwnd;
    MSG msg;
    WNDCLASSEX wcx;
    INITCOMMONCONTROLSEX icx = {sizeof(icx), ICC_STANDARD_CLASSES | ICC_UPDOWN_CLASS};

    AllocConsole();
    h_con_out = GetStdHandle(STD_OUTPUT_HANDLE);

    memset(&wcx, 0, sizeof(wcx));
    wcx.cbSize = sizeof(wcx);
    wcx.lpfnWndProc = WndProc;
    wcx.hInstance = hInstance;
    wcx.hCursor = LoadCursor(NULL, IDC_ARROW);
    wcx.hbrBackground = (HBRUSH) (COLOR_BTNFACE + 1);
    wcx.lpszClassName = app_name;

    if(!RegisterClassEx(&wcx)){
        MessageBox(NULL, TEXT("This program requires Windows 2000!"), app_name, MB_ICONERROR);
        return 0;
    }
    InitCommonControlsEx(&icx);

    hwnd = CreateWindowEx(
        0, app_name, app_name, 
        WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX,
        CW_USEDEFAULT, CW_USEDEFAULT, 200, 100,
        NULL, NULL, hInstance, NULL
    );
    ShowWindow(hwnd, iCmdShow);
    UpdateWindow(hwnd);

    while((GetMessage(&msg, NULL, 0, 0)) != 0){
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }

    return msg.wParam;
}

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam){
    static HWND hEd, hUd;

    switch(msg){
        case WM_CREATE:
            hEd = CreateWindowEx(
                WS_EX_CLIENTEDGE, WC_EDIT, NULL,
                WS_VISIBLE | WS_CHILD | WS_BORDER |
                ES_RIGHT | ES_NUMBER,
                5, 5, 52, 23,
                hwnd, NULL, ((LPCREATESTRUCT) lParam)->hInstance, NULL
            );
            hUd = CreateWindowEx(
                0, UPDOWN_CLASS, NULL,
                WS_VISIBLE | WS_CHILD |
                UDS_ALIGNRIGHT | UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_AUTOBUDDY | UDS_HOTTRACK | UDS_SETBUDDYINT | UDS_AUTOBUDDY,
                0, 0, 0, 0,
                hwnd, NULL, ((LPCREATESTRUCT) lParam)->hInstance, NULL
            );

            SendMessage(hUd, UDM_SETRANGE, 0, 10 | 1 << 16);
            return 0;

        case WM_DESTROY:
            PostQuitMessage(0);         
            return 0;
    }

    return DefWindowProc(hwnd, msg, wParam, lParam);
}
#包括
#包括
#包括
#定义print(…)sprintf(dbg,_uva_ARGS_uu)\
WriteConsoleA(h_con_out,dbg,strlen(dbg),NULL,NULL)
TCHAR*应用程序名称=文本(“ud”);
处理h_con_out;
char-dbg[80];
LRESULT回调WndProc(HWND HWND、UINT msg、WPARAM WPARAM、LPARAM LPARAM);
int WINAPI WinMain(HINSTANCE HINSTANCE、HINSTANCE hPrevInstance、PSTR szCmdLine、int iCmdShow){
HWND-HWND;
味精;
WNDCLASSEX wcx;
INITCOMMONCONTROLSEX icx={sizeof(icx),ICC_标准_类| ICC_UPDOWN_类};
allocsole();
h_con_out=GetStdHandle(标准输出句柄);
memset(&wcx,0,sizeof(wcx));
wcx.cbSize=sizeof(wcx);
wcx.lpfnWndProc=WndProc;
wcx.hInstance=hInstance;
wcx.hCursor=LoadCursor(空,IDC_箭头);
wcx.hbrBackground=(HBRUSH)(颜色面+1);
wcx.lpszClassName=应用程序名称;
如果(!RegisterClass(&wcx)){
MessageBox(NULL,文本(“此程序需要Windows 2000!”)、应用程序名称、MB\U ICONERROR);
返回0;
}
InitCommonControlsEx(&icx);
hwnd=CreateWindowEx(
0,应用程序名称,应用程序名称,
WS|U重叠| WS|U标题| WS|U系统菜单| WS|U最小化盒带,
CW_USEDEFAULT,CW_USEDEFAULT,200100,
空的,空的,空的
);
显示窗口(hwnd、iCmdShow);
更新窗口(hwnd);
while((GetMessage(&msg,NULL,0,0))!=0){
翻译信息(&msg);
发送消息(&msg);
}
返回msg.wParam;
}
LRESULT回调WndProc(HWND HWND,UINT msg,WPARAM WPARAM,LPARAM LPARAM){
静态HWND hEd,hUd;
开关(msg){
案例WM_创建:
hEd=CreateWindowEx(
WS_EX_客户端,WC_编辑,空,
WS|U可见| WS|U儿童| WS|U边框|
ES|U RIGHT | ES|U编号,
5, 5, 52, 23,
hwnd,NULL,((LPCREATESTRUCT)lParam)->hInstance,NULL
);
hUd=CreateWindowEx(
0,UPDOWN_类,NULL,
WS|u可见| WS|u儿童|
UDS|U右对齐| UDS|U箭头键| UDS|U上千个| UDS|U自动预算| UDS|U热跟踪| UDS|U设置预算| UDS|U自动预算,
0, 0, 0, 0,
hwnd,NULL,((LPCREATESTRUCT)lParam)->hInstance,NULL
);

SendMessage(hUd、UDM|U设置范围、0、10|1从编辑控件样式中删除
WS|u边框

从编辑控件样式中删除
WS|u边框

是否是应用程序主题化?Windows 7中的按钮(至少)在其窗口矩形内有一个像素“间隙”。是否是应用程序主题化?Windows 7中的按钮(至少)在其窗口矩形内有一个像素“间隙”。