C语言的GUI

时间:2017-12-10 14:19:05

标签: c user-interface

我正在构建多个程序的gui,我想将它们组合在一个窗口中,用户可以通过该窗口初步选择要运行的程序。仅显示所选程序的窗口。我的问题:当我选择一个程序时,该程序下的功能不起作用,即:

开关(MSG)
    {         案例WM_CLOSE:             的DestroyWindow(HWND);
            打破;         案例WM_DESTROY:             PostQuitMessage(0);
            打破;

    case WM_CREATE:
        Main_createButton(hwnd);

    break;


    //____________________________________________________________________

    case WM_COMMAND:

        switch (LOWORD(wparam))
        {

            case Main_ID_RB_a:


                Q1_createButton(hwnd);
                Q1_picture(hwnd);
                Q1_Rad_But(hwnd);
                Q1_D_Price (hwnd);
                Q1_Comb_Box (hwnd);
                Q1_money_shwbox (hwnd);


               switch (Q1_Rad_But(hwnd))
        {
            case Q1_ID_BUTTON_FIRST:
                Q1_pressButton(hwnd);
            break;

            case Q1_ID_RB_a:

                SetDlgItemText(hwnd,Q1_ID_EDIT_TEXT1,"Apple Doughnut");
                SetDlgItemText(hwnd,Q1_ID_EDIT_TEXT2,"5.30");
            break;
            case Q1_ID_RB_b:
                SetDlgItemText(hwnd,Q1_ID_EDIT_TEXT1,"Cheese Doughnut");
                SetDlgItemText(hwnd,Q1_ID_EDIT_TEXT2,"5.20");
            break;
            case Q1_ID_RB_c:
                SetDlgItemText(hwnd,Q1_ID_EDIT_TEXT1,"Chocolate Doughnut");
                SetDlgItemText(hwnd,Q1_ID_EDIT_TEXT2,"4.30");
            break;
            case Q1_ID_RB_d:
                SetDlgItemText(hwnd,Q1_ID_EDIT_TEXT1,"Cruller Doughnut");
                SetDlgItemText(hwnd,Q1_ID_EDIT_TEXT2,"4.50");
            break;
            case Q1_ID_RB_e:
                SetDlgItemText(hwnd,Q1_ID_EDIT_TEXT1,"Glaze Doughnut");
                SetDlgItemText(hwnd,Q1_ID_EDIT_TEXT2,"4.50");
            break;
            case Q1_ID_RB_f:
                SetDlgItemText(hwnd,Q1_ID_EDIT_TEXT1,"Jelly Doughnut");
                SetDlgItemText(hwnd,Q1_ID_EDIT_TEXT2,"4");
            break;
            case Q1_ID_RB_g:
                SetDlgItemText(hwnd,Q1_ID_EDIT_TEXT1,"Muffin Doughnut");
                SetDlgItemText(hwnd,Q1_ID_EDIT_TEXT2,"5");
            break;
            case Q1_ID_RB_h:
                SetDlgItemText(hwnd,Q1_ID_EDIT_TEXT1,"Pumpkin Doughnut");
                SetDlgItemText(hwnd,Q1_ID_EDIT_TEXT2,"3.30");
            break;
            case Q1_ID_RB_i:
                SetDlgItemText(hwnd,Q1_ID_EDIT_TEXT1,"Strawberry Doughnut");
                SetDlgItemText(hwnd,Q1_ID_EDIT_TEXT2,"4.70");
            break;
            case Q1_ID_RB_j:
                SetDlgItemText(hwnd,Q1_ID_EDIT_TEXT1,"Sugar Doughnut");
                SetDlgItemText(hwnd,Q1_ID_EDIT_TEXT2,"3");
            break;



                //destroy Q2
                DestroyWindow(Q2S11);  DestroyWindow(Q2S12) ;DestroyWindow(Q2S13) ;DestroyWindow(Q2S14) ;DestroyWindow(Q2S15) ;
                DestroyWindow(Q2S16);  DestroyWindow(Q2S17);  DestroyWindow(Q2S18);  DestroyWindow(Q2S19);  DestroyWindow( Q2S110);
                DestroyWindow(Q2S111);  DestroyWindow(Q2S112);  DestroyWindow(Q2S113);  DestroyWindow(Q2S114);  DestroyWindow(Q2S115);
                DestroyWindow(Q2S116);  DestroyWindow(Q2S117);  DestroyWindow(Q2S118);  DestroyWindow(Q2S119);  DestroyWindow(Q2S120);
                DestroyWindow(Q2S121);  DestroyWindow(Q2S122);  DestroyWindow(Q2S123);  DestroyWindow(Q2S124);  DestroyWindow(Q2S125);

                DestroyWindow(Q2E11) ;DestroyWindow(Q2E12) ;DestroyWindow(Q2E13) ;DestroyWindow(Q2E14);DestroyWindow( Q2E15);
                DestroyWindow(Q2E16);  DestroyWindow(Q2E17);  DestroyWindow(Q2E18);  DestroyWindow(Q2E19); DestroyWindow(Q2E110);
                DestroyWindow(Q2E111);  DestroyWindow(Q2E112);

                DestroyWindow(Q2B1a);DestroyWindow(Q2B1b);DestroyWindow(Q2B1c);DestroyWindow(Q2B1d);DestroyWindow(Q2B1e);
                DestroyWindow(Q2B1f);DestroyWindow(Q2B1g);DestroyWindow(Q2B1h);DestroyWindow(Q2B1i);DestroyWindow(Q2B1j);
                DestroyWindow(Q2B1sel);

                DestroyWindow(Q2_staticText);DestroyWindow(Q2_staticText1);DestroyWindow(Q2_staticText2);DestroyWindow(Q2_staticText3);
                DestroyWindow(Q2_staticText4);DestroyWindow(Q2_staticText5);DestroyWindow(Q2_staticText6);DestroyWindow(Q2_staticText7);
                DestroyWindow(Q2_staticText8);DestroyWindow(Q2_staticText9);

                DestroyWindow(Q2_hBitmap);DestroyWindow(Q2_hBitmap1);DestroyWindow(Q2_hBitmap2);DestroyWindow(Q2_hBitmap3);
                DestroyWindow(Q2_hBitmap4);DestroyWindow(Q2_hBitmap5);DestroyWindow(Q2_hBitmap6);DestroyWindow(Q2_hBitmap7);
                DestroyWindow(Q2_hBitmap8);DestroyWindow(Q2_hBitmap9);

                DestroyWindow(Q2hComboBox);

                DestroyWindow(Q2B11);
                }


            break;

当选择一个项目并且程序没有复制名称和值以编辑文本1并编辑文本二如图所示 enter image description here [在此输入图片说明] [2]

1 个答案:

答案 0 :(得分:1)

标准C99或C11不了解GUI和小部件。您可以通过阅读n1570(基本上是最新的C标准规范)进行检查。

所以你将使用一些widget toolkit库(可能在某些特定的operating system下运行)。我建议使用GTK(跨平台)。

然后你可以让你的GTK程序运行其他程序。或者你可以(这有点困难)收集每个代码创建的所有窗口。

(一般来说,你的问题非常具体,并且没有明显的答案;它甚至可能是display server特定的;在某些情况下,你可以认为你的程序表现得像{{3} }})功能