24小时热门版块排行榜    

查看: 7744  |  回复: 145
本帖产生 1 个 程序强帖 ,点击这里进行查看
当前只显示满足指定条件的回帖,点击这里查看本话题的所有回帖

magic7004

金虫 (职业作家)

[交流] 【交流】VC++, C#, VB答疑专贴 已有69人参与

帖主寄语


其实我是业余爱好者,不搞研究也不写论文,专业和工作都和编程基本没关系。只是喜欢胡搞瞎搞而已,所以对Windows编程比较熟悉,数值计算之类的就不懂了。

比较熟悉Windows编程,常用VB、VC++、C#。关于语言、语法和编译的问题,欢迎大家一起来交流讨论~.~



[ Last edited by 波不动 on 2010-1-8 at 19:44 ]
回复此楼
流氓不可怕,可怕的是流氓有文化,有文化又BH的流氓无敌~~!
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

biowhb

银虫 (正式写手)


小木虫: 金币+0.5, 给个红包,谢谢回帖
初学windows编程:想把一个主窗体的客户区分割成三个部分,下面是代码,运行起来却仍是空白的没什么变化,这是为何?求大神指点
#include <windows.h>

#define ID_FIRSTCHILD  100
#define ID_SECONDCHILD 101
#define ID_THIRDCHILD  102

// Global variable

HINSTANCE hinst;

// Function prototypes.

int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int);
InitApplication(HINSTANCE);
InitInstance(HINSTANCE, int);
LRESULT CALLBACK MainWndProc(HWND, UINT, WPARAM, LPARAM);
BOOL CALLBACK EnumChildProc(HWND , LPARAM ) ;

// Application entry point.

int WINAPI WinMain(HINSTANCE hinstance, HINSTANCE hPrevInstance,
    LPSTR lpCmdLine, int nCmdShow)
{
    MSG msg;

    if (!InitApplication(hinstance))
        return FALSE;

    if (!InitInstance(hinstance, nCmdShow))
        return FALSE;

    while (GetMessage(&msg, (HWND) NULL, 0, 0) != 0 && GetMessage(&msg, (HWND) NULL, 0, 0) != -1)
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    return msg.wParam;
        UNREFERENCED_PARAMETER(lpCmdLine);
}

BOOL InitApplication(HINSTANCE hinstance)
{
    WNDCLASSEX wcx;

    // Fill in the window class structure with parameters
    // that describe the main window.

    wcx.cbSize = sizeof(wcx);          // size of structure
    wcx.style = CS_HREDRAW |
        CS_VREDRAW;                    // redraw if size changes
    wcx.lpfnWndProc = MainWndProc;     // points to window procedure
    wcx.cbClsExtra = 0;                // no extra class memory
    wcx.cbWndExtra = 0;                // no extra window memory
    wcx.hInstance = hinstance;         // handle to instance
    wcx.hIcon = LoadIcon(NULL,
        IDI_APPLICATION);              // predefined app. icon
    wcx.hCursor = LoadCursor(NULL,
        IDC_ARROW);                    // predefined arrow
    wcx.hbrBackground = (HBRUSH)GetStockObject(
        WHITE_BRUSH);                  // white background brush
    wcx.lpszMenuName =  "MainMenu";    // name of menu resource
    wcx.lpszClassName = "MainWClass";  // name of window class
    wcx.hIconSm = NULL;

    // Register the window class.

    return RegisterClassEx(&wcx);
}

BOOL InitInstance(HINSTANCE hinstance, int nCmdShow)
{
    HWND hwnd;

    // Save the application-instance handle.

    hinst = hinstance;

    // Create the main window.

    hwnd = CreateWindow(
        "MainWClass",        // name of window class
        "Sample",            // title-bar string
        WS_OVERLAPPEDWINDOW, // top-level window
        CW_USEDEFAULT,       // default horizontal position
        CW_USEDEFAULT,       // default vertical position
        CW_USEDEFAULT,       // default width
        CW_USEDEFAULT,       // default height
        (HWND) NULL,         // no owner window
        (HMENU) NULL,        // use class menu
        hinstance,           // handle to application instance
        (LPVOID) NULL);      // no window-creation data

    if (!hwnd)
        return FALSE;

    // Show the window and send a WM_PAINT message to the window
    // procedure.

    ShowWindow(hwnd, nCmdShow);
    UpdateWindow(hwnd);
    return TRUE;

}

LONG APIENTRY MainWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    RECT rcClient;
    int i;

    switch(uMsg)
    {
        case WM_CREATE: // creating main window  

            // Create three invisible child windows.

            for (i = 0; i < 3; i++)
            {
                CreateWindowEx(
                    0,
                    "ChildWClass",
                    (LPCTSTR) NULL,
                    WS_CHILD | WS_BORDER,
                    0,0,0,0,
                    hwnd,
                    (HMENU) (int) (ID_FIRSTCHILD + i),
                    hinst,
                    NULL);
            }

            return 0;

        case WM_SIZE:   // main window changed size

            // Get the dimensions of the main window's client
            // area, and enumerate the child windows. Pass the
            // dimensions to the child windows during enumeration.

            GetClientRect(hwnd, &rcClient);
            EnumChildWindows(hwnd, EnumChildProc,
                (LPARAM) &rcClient);
            return 0;
        // Process other messages.

    }
    return DefWindowProc(hwnd, uMsg, wParam, lParam);
}

BOOL CALLBACK EnumChildProc(HWND hwndChild, LPARAM lParam)
{
    LPRECT rcParent;
    int i, idChild;

    // Retrieve the child-window identifier. Use it to set the
    // position of the child window.

    idChild = GetWindowLong(hwndChild, GWL_ID);

    if (idChild == ID_FIRSTCHILD)
        i = 0;
    else if (idChild == ID_SECONDCHILD)
        i = 1;
    else
        i = 2;

    // Size and position the child window.  

    rcParent = (LPRECT) lParam;
    MoveWindow(hwndChild,
        (rcParent->right / 3) * i,
        0,
        rcParent->right / 3,
        rcParent->bottom,
        TRUE);

    // Make sure the child window is visible.

    ShowWindow(hwndChild, SW_SHOW);

    return TRUE;
}
生物技术-基因工程制药
133楼2014-02-13 15:26:09
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
查看全部 146 个回答

jjdg

版主 (知名作家)

优秀版主


小木虫(金币+0.5):给个红包,谢谢回帖交流
我也常用vb,不过都是写注册机啦!小东东而已!
努力学习!以正当途径!获得需要的知识!
3楼2009-11-20 15:21:38
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

magic7004

金虫 (职业作家)

引用回帖:
Originally posted by jjdg at 2009-11-20 15:21:
我也常用vb,不过都是写注册机啦!小东东而已!

注册机,好强大!

我用vb比较少用其实,最近VC用的多,不过已经在转型C#了
流氓不可怕,可怕的是流氓有文化,有文化又BH的流氓无敌~~!
4楼2009-11-20 15:26:06
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

senlia

木虫 (小有名气)


小木虫(金币+0.5):给个红包,谢谢回帖交流
同志们 为什么 没有人提问题啊?
书到用时方恨少, 天涯何处无芳草.
5楼2009-11-22 19:48:23
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
普通表情 高级回复 (可上传附件)
信息提示
请填处理意见