-- 作者:lm_lxt
-- 发布时间:2006/12/10 18:03:16
--
下面是六楼所示界面的源码,大家共同探讨!module hh integer hInst integer hDlg end module hh integer function WinMain( hInstance, hPrevInstance, lpszCmdLine, nCmdShow ) !DEC$ IF DEFINED(_X86_) !DEC$ ATTRIBUTES STDCALL, ALIAS : \'_WinMain@16\' :: WinMain !DEC$ ELSE !DEC$ ATTRIBUTES STDCALL, ALIAS : \'WinMain\' :: WinMain !DEC$ ENDIF !包含有用的模块 use user32 use dfwin use hh USE clipinc integer hInstance !定义句柄 integer hPrevInstance !定义句柄 integer nCmdShow integer lpszCmdLine !***************************************************************** interface integer*4 function MainWndProc ( hwnd, mesg, wParam, lParam ) !DEC$ IF DEFINED(_X86_) !DEC$ ATTRIBUTES STDCALL, ALIAS : \'_MainWndProc@16\' :: MainWndProc !DEC$ ELSE !DEC$ ATTRIBUTES STDCALL, ALIAS : \'MainWndProc\' :: MainWndProc !DEC$ ENDIF integer*4 hwnd integer*4 mesg integer*4 wParam integer*4 lParam end function end interface !****************************************************************** type (T_WNDCLASS) wc type (T_MSG) mesg integer hWnd,COLOR character*100 lpszClassName,lpszAppName,lpszMenuName COLOR=9 !这个用来改变窗口的背景颜色 lpszCmdLine = lpszCmdLine nCmdShow = nCmdShow lpszClassName ="Generic"C lpszAppName ="窗口程序,非模态对话框"C lpszMenuName="menumenu"C
if(hPrevInstance .eq. 0) then wc%lpszClassName = LOC(lpszClassName) wc%lpfnWndProc = LOC(MainWndProc) wc%style = IOR(CS_VREDRAW , CS_HREDRAW) wc%hInstance = hInstance wc%hIcon = LoadIcon( hInstance, "MYICON") wc%hCursor = LoadCursor( hInstance, "MYCURSOR" ) wc%hbrBackground = ( COLOR_WINDOW+COLOR ) wc%lpszMenuName = LOC(lpszMenuName) wc%cbClsExtra = 0 wc%cbWndExtra = 0 i1 = RegisterClass(wc) end if hWnd = CreateWindowEx( 0, lpszClassName, & lpszAppName, & INT(WS_OVERLAPPEDWINDOW), & CW_USEDEFAULT, & 0, & CW_USEDEFAULT, & 0, & NULL, & NULL, & hInstance, & NULL & ) hInst=hInstance i = ShowWindow( hWnd, SW_SHOWNORMAL) do while( GetMessage (mesg, NULL, 0, 0)) if(IsDialogMessage(hDlg,mesg)==0)then i = TranslateMessage( mesg ) i = DispatchMessage( mesg ) endif end do WinMain = mesg%wParam end !*********************************以下是窗口处理函数************* integer function MainWndProc (hWnd, mesg, wParam, lParam) !DEC$ IF DEFINED(_X86_) !DEC$ ATTRIBUTES STDCALL, ALIAS : \'_MainWndProc@16\' :: MainWndProc !DEC$ ELSE !DEC$ ATTRIBUTES STDCALL, ALIAS : \'MainWndProc\' :: MainWndProc !DEC$ ENDIF use user32 use dfwin use hh USE clipinc !***************************************************************** interface logical function DialogFunc ( hdWnd, mesg, wParam, lParam ) !DEC$ IF DEFINED(_X86_) !DEC$ ATTRIBUTES STDCALL, ALIAS : \'_DialogFunc@16\' :: DialogFunc !DEC$ ELSE !DEC$ ATTRIBUTES STDCALL, ALIAS : \'DialogFunc\' :: DialogFunc !DEC$ ENDIF integer*4 hdWnd integer*4 mesg integer*4 wParam integer*4 lParam end function end interface !****************************************************************** integer hWnd, mesg, wParam, lParam select case ( mesg ) case(WM_COMMAND) select case(LOWORD(wParam)) case(IDM_OPEN) hDlg=CreateDialog(hInst, LOC("AboutBox"C),hWnd,LOC(DialogFunc)) case(IDM_DIALOG) call PostQuitMessage( 0 ) end select case (WM_DESTROY) call PostQuitMessage( 0 ) case default MainWndProc = DefWindowProc( hWnd, mesg, wParam, lParam ) return end select end !**********************对话框窗口函数*********************** logical function DialogFunc( hdWnd, mesg, wParam, lParam ) !DEC$ IF DEFINED(_X86_) !DEC$ ATTRIBUTES STDCALL, ALIAS : \'_DialogFunc@16\' :: DialogFunc !DEC$ ELSE !DEC$ ATTRIBUTES STDCALL, ALIAS : \'DialogFunc\' :: DialogFunc !DEC$ ENDIF use user32 use dfwin USE clipinc use hh integer hdWnd, mesg, wParam, lParam integer*4 i logical logresult,F,T character*100 string F=1<0 !F的值为FALSE T=1>0 !T的值为TRUE
select case (mesg) case (WM_COMMAND) select case(LOWORD(wParam)) case(IDOK) logresult=DestroyWindow(hdWnd) DialogFunc=T RETURN case(IDCANCEL) logresult=DestroyWindow(hdWnd) DialogFunc=T RETURN case(IDC_LIST1) if(HIWORD(wParam)==LBN_DBLCLK)THEN i=SendDlgItemMessage(hdWnd,IDC_LIST1,LB_GETCURSEL,0,0) write(string,"(\'你已经选择了第\',I3,\'项!\')")i i=MessageBox(hdWnd,string,"提示框",MB_OK) ENDIF DialogFunc=T RETURN case(IDC_SELECT) i=SendDlgItemMessage(hdWnd,IDC_LIST1,LB_GETCURSEL,0,0) if(i==LB_ERR)THEN write(string,"(\'你没有作出选择!\')") else write(string,"(\'你已经选择了第\',I3,\'项!\')")i endif i=MessageBox(hdWnd,string,"提示框",MB_OK) DialogFunc=T RETURN case(IDC_EDITOK) i=GetDlgItemText(hdWnd,IDC_EDIT,string,100) i=MessageBox(hdWnd,string,"你输入的内容为:",MB_OK) DialogFunc=T RETURN end select case(WM_INITDIALOG) i=SendDlgItemMessage(hdWnd,IDC_LIST1,LB_ADDSTRING,0,LOC("计算机"C)) i=SendDlgItemMessage(hdWnd,IDC_LIST1,LB_ADDSTRING,0,LOC("物 理"C)) i=SendDlgItemMessage(hdWnd,IDC_LIST1,LB_ADDSTRING,0,LOC("数 学"C)) i=SendDlgItemMessage(hdWnd,IDC_LIST1,LB_ADDSTRING,0,LOC("语 文"C)) i=SendDlgItemMessage(hdWnd,IDC_LIST1,LB_ADDSTRING,0,LOC("英 语"C)) i=SendDlgItemMessage(hdWnd,IDC_LIST1,LB_ADDSTRING,0,LOC("历 史"C)) i=SendDlgItemMessage(hdWnd,IDC_LIST1,LB_ADDSTRING,0,LOC("地 理"C)) i=SendDlgItemMessage(hdWnd,IDC_LIST1,LB_ADDSTRING,0,LOC("生 物"C)) DialogFunc=T RETURN end select DialogFunc=F RETURN end [此贴子已经被作者于2006-12-10 18:04:37编辑过]
|