当前位置: 网学 > 编程文档 > VB > 正文

使用API创建窗体(类似VC的创建过程)

来源:Http://myeducs.cn 联系QQ:点击这里给我发消息 作者: 用户投稿 来源: 网络 发布时间: 12/10/16
下载{$ArticleTitle}原创论文样式
p;   ''''Loop will exit when WM_QUIT is sent to the window.
         Do While GetMessage(wMsg, 0&, 0&, 0&)
            ''''TranslateMessage takes keyboard messages and converts
            ''''them to WM_CHAR for easier processing.
            Call TranslateMessage(wMsg)
            ''''Dispatchmessage calls the default window procedure
            ''''to process the window message. (WndProc)
            Call DispatchMessage(wMsg)
         Loop
      End If

    Call UnregisterClass(gClassName$, App.hInstance)


End Sub

Public Function RegisterWindowClass() As Boolean

    Dim wc As WNDCLASS
    
    
    wc.style = CS_HREDRAW Or CS_VREDRAW
    wc.lpfnwndproc = GetAddress(AddressOf WndProc) ''''Address in memory of default window procedure.
    wc.hInstance = App.hInstance
    wc.hIcon = LoadIcon(0&, IDI_APPLICATION) ''''Default application icon
    wc.hCursor = LoadCursor(0&, IDC_ARROW) ''''Default arrow
    wc.hbrBackground = COLOR_WINDOW ''''Default a color for window.
    wc.lpszClassName = gClassName$

    RegisterWindowClass = RegisterClass(wc) <> 0
    
End Function
Public Function CreateWindows() As Boolean
  
    ''''开始创建窗体

主窗体.
    gHwnd& = CreateWindowEx(0&, gClassName$, gAppName$, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, 208, 150, 0&, 0&, App.hInstance, ByVal 0&)
    ''''创建一个按钮
    gButtonHwnd& = CreateWindowEx(0&, "Button", "Click Here", WS_CHILD, 58, 90, 85, 25, gHwnd&, 0&, App.hInstance, 0&)
    ''''创建一个(WS_EX_CLIENTEDGE、ES_MULTILINE风格的TextBox
    gEditHwnd& = CreateWindowEx(WS_EX_CLIENTEDGE, "Edit", "This is the edit control." & vbCrLf & "As you can see, it''s multiline.", WS_CHILD Or ES_MULTILINE, 0&, 0&, 200, 80, gHwnd&, 0&, App.hInstance, 0&)

"Button ","Edit"系统中已经注册过了所以这里直接用
    创建完别忘了显示出来否则是隐藏的

    Call ShowWindow(gHwnd&, SW_SHOWNORMAL)
    Call ShowWindow(gButtonHwnd&, SW_SHOWNORMAL)
   &nb

网学推荐

免费论文

原创论文

浏览:
设为首页 | 加入收藏 | 论文首页 | 论文专题 | 设计下载 | 网学软件 | 论文模板 | 论文资源 | 程序设计 | 关于网学 | 站内搜索 | 网学留言 | 友情链接 | 资料中心
版权所有 QQ:3710167 邮箱:3710167@qq.com 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
Copyright 2008-2015 myeducs.Cn www.myeducs.Cn All Rights Reserved
湘ICP备09003080号