zoukankan      html  css  js  c++  java
  • 一个对话框程序dlg1

     

     

    MainDlg.cpp

    #include "stdafx.h"

    #include <windows.h>

    #include <stdio.h>

    #include <windowsx.h>

    #include "resource.h"

    #include "MainDlg.h"

     

    //程序写的不够完善,还有待优化

     

     

    BOOL WINAPI Main_Proc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)

    {

    switch(uMsg)

    {

    HANDLE_MSG(hWnd, WM_INITDIALOG, Main_OnInitDialog);

    HANDLE_MSG(hWnd, WM_COMMAND, Main_OnCommand);

            HANDLE_MSG(hWnd,WM_CLOSE, Main_OnClose);

    }

     

    return FALSE;

    }

     

    BOOL Main_OnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)

    {

    return TRUE;

    }

     

    void Main_OnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)

    {

    switch(id)

    {

    case IDC_OK:

                {

                    MessageBox(hwnd,TEXT("欢迎,欢迎,热烈欢迎,你好!祝你非常好!"),TEXT("问好"),MB_OK);

                }

    break;

            case IDC_CHUNGE:

                {

                    MessageBox(hwnd,TEXT("信春哥,得永生"),TEXT("李宇春"),MB_OK);

                }

            break;

            case ID_MENUITEMOPEN:

                {

                    FILE* fp=fopen("./op_file.txt","r+");

                    char fstr[1024]="";

                    //char * fstr;

                    //while()

                    //int i;

                    int j=0;

                    char ch;

                    while(ch!=EOF)

                    {

                        ch=fgetc(fp);

                        fstr[j]=ch;

                        //i=fscanf(fp,"%d",fstr[j]);

                        j++;

                    }//fstr[j]="HT";

                    /*for(j;j<10240;j++)

                    {

                        if(EOF!=fscanf(fp,"%d",fstr+j))

                            continue;

                    }*/

                    fclose(fp);

                    SetDlgItemText(hwnd,IDC_RICHEDIT,TEXT(fstr));

                    SetDlgItemText(hwnd,IDC_EDIT,TEXT(fstr));

                    

                }break;

            case ID_MENUITEMQUIT:

                {

                    EndDialog(hwnd,IDD_MAIN);

                    MessageBox(hwnd,TEXT("[退出]菜单被调用!"),TEXT("提示"),MB_OK);

                }break;

    default:

            break;

    }

    }

     

    void Main_OnClose(HWND hwnd)

    {

    EndDialog(hwnd, 0);

    }

     

    截图:

     

  • 相关阅读:
    Attributes in C#
    asp.net C# 时间格式大全
    UVA 10518 How Many Calls?
    UVA 10303 How Many Trees?
    UVA 991 Safe Salutations
    UVA 10862 Connect the Cable Wires
    UVA 10417 Gift Exchanging
    UVA 10229 Modular Fibonacci
    UVA 10079 Pizza Cutting
    UVA 10334 Ray Through Glasses
  • 原文地址:https://www.cnblogs.com/luowei010101/p/2170155.html
Copyright © 2011-2022 走看看