精华内容
下载资源
问答
  • VB为自己的程序设定消息(可接收处理)Posted by JiaJia 5 March,2009 (0)Comment 用API函数 SetWindowLong 指定处理消息的窗口过程为自定义的函数 WindowProc,捕获消息ID为 WM_USER+1 的自定义消息或系统消息。...

    VB为自己的程序设定消息(可接收处理)

    Posted by JiaJia 5 March,2009 (0)Comment   用API函数 SetWindowLong 指定处理消息的窗口过程为自定义的函数 WindowProc,捕获消息ID为 WM_USER+1 的自定义消息或系统消息。并且,为了保证窗口能正确的响应消息,需要保存原来默认的窗口过程并在自定义函数WindowProc中调用。如下例,在按钮事件中发送自定义消息,WindowProc 捕获了窗口大小变化的系统定义消息和用户自定义的消息并显示用户自定义的消息参数 wParam。

    Form 部分代码

    Private Sub Command1_Click()

    Dim wParam As Long

    Dim lParam As Long

    Dim lResult As Long

    wParam = 12345

    lResult = SendMessage(Me.hwnd, WM_USER + 1, wParam, lParam)

    End Sub

    Private Sub Form_Load()

    Me.Tag = Hook(Me.hwnd)

    End Sub

    Private Sub Form_Unload(Cancel As Integer)

    Unhook Me.hwnd, Me.Tag

    End Sub

    Mod 部分代码

    Option Explicit

    Private Declare Function CallWindowProc Lib "user32" Alias _

    "CallWindowProcA" (ByVal lpPrevWndFunc As Long, _

    ByVal hwnd As Long, ByVal Msg As Long, _

    ByVal wParam As Long, ByVal lParam As Long) As Long

    Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" _

    (ByVal hwnd As Long, ByVal nIndex As Long) As Long

    Private Declare Function SetWindowLong Lib "user32" Alias _

    "SetWindowLongA" (ByVal hwnd As Long, _

    ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

    Public Declare Function SendMessage Lib "user32" Alias _

    "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _

    ByVal wParam As Long, lParam As Any) As Long

    Private Const GWL_WNDPROC = -4

    Public Const GWL_USERDATA = (-21)

    Public Const WM_SIZE = &H5

    Public Const WM_USER = &H400

    Public Function Hook(ByVal hwnd As Long) As Long

    Dim pOld As Long

    '指定自定义的窗口过程

    pOld = SetWindowLong(hwnd, GWL_WNDPROC, AddressOf WindowProc)

    '保存原来默认的窗口过程指针

    SetWindowLong hwnd, GWL_USERDATA, pOld

    Hook = pOld

    End Function

    Public Sub Unhook(ByVal hwnd As Long, ByVal lpWndProc As Long)

    Dim temp As Long

    '注释:Cease subclassing.

    temp = SetWindowLong(hwnd, GWL_WNDPROC, lpWndProc)

    End Sub

    Function WindowProc(ByVal hw As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

    If uMsg = WM_SIZE Then

    '处理WM_SIZE消息

    MsgBox "收到消息 WM_SIZE"

    End If

    If uMsg = WM_USER + 1 Then

    MsgBox wParam

    End If

    Dim lpPrevWndProc As Long

    '查询原来默认的窗口过程指针

    lpPrevWndProc = GetWindowLong(hw, GWL_USERDATA)

    '调用原来的窗口过程

    WindowProc = CallWindowProc(lpPrevWndProc, hw, uMsg,wParam, lParam)

    End Function

    展开全文
  • VB6 时间戳函数

    千次阅读 2019-06-29 14:53:46
    Private Const TimeZone_China As Long = &H8 '中国(北京)时区[东八区] Private Const TimeStamp_Base As Date = #1/1/1970# '时间戳起始时间:1970年1月1日 0时0分0秒 Private Const TimeSt...
    '时间戳常量
    Private Const TimeZone_China As Long = &H8                      '中国(北京)时区[东八区]
    Private Const TimeStamp_Base As Date = #1/1/1970#               '时间戳起始时间:1970年1月1日 0时0分0秒
    Private Const TimeStamp_Max As Date = #1/19/2038 11:14:07 AM#   '时间戳最大值(&H7FFFFFFF)
    Private Const TimeStamp_Min As Date = #12/14/1901 4:45:52 AM#   '时间戳最小值(&H80000000)
    '日期格式转时间戳,默认加上东八区(北京时间)的时差
    Public Function TimeStampFromDate(Optional TimeStamp As Date, Optional TimeZone As Long = TimeZone_China) As Long
        Dim DateTimeStamp As Date
        If TimeStamp > TimeStamp_Max Or TimeStamp < TimeStamp_Min Then TimeStamp = Now
        DateTimeStamp = DateAdd("h", -TimeZone, TimeStamp)
        TimeStampFromDate = DateDiff("s", TimeStamp_Base, DateTimeStamp)
    End Function
    '时间戳转日期格式,默认除去东八区(北京时间)的时差
    Public Function TimeStampToDate(TimeStamp As Long, Optional TimeZone As Long = TimeZone_China) As Date
        Dim DateTimeStamp As Date
        DateTimeStamp = DateAdd("s", TimeStamp, TimeStamp_Base)
        TimeStampToDate = DateAdd("h", TimeZone, DateTimeStamp)
    End Function
    
    Private Sub Form_Load()
        Debug.Print "TimeStampTest", TimeStampFromDate(Now), TimeStampToDate(TimeStampFromDate(Now))
        Unload Me
    End Sub
    
    展开全文
  • vb窗口置顶函数

    2010-09-08 12:43:00
    模块函数 Public Type POINT  X As Long  Y As Long End Type <br />Public capture As Boolean Public CursorPosition As POINT <br />Global Const WM_GETTEXT = &HD...

    模块函数

    Public Type POINT
        X As Long
        Y As Long
    End Type


    Public capture As Boolean
    Public CursorPosition As POINT


    Global Const WM_GETTEXT = &HD
    Global Const WM_GETTEXTENGTH = &HE
    Global Const HWND_TOPMOST = -1
    Global Const HWND_NOTOPMOST = -2
    Global Const SWP_NOACTIVATE = &H10
    Global Const SWP_SHOWWINDOW = &H40
        Public Declare Function GetCursorpos Lib "user32" (ByRef lpPoint As POINT) As Long
        Public Declare Function WindowFromPoint Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
        Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
        Public Declare Function SendMessagebystring Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As String) As Long
        Public Declare Sub SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)
     窗体函数(option)

    Private Sub Check1_click()
    If Check1.Value = 1 Then
      SetWindowPos Form1.hwnd, HWND_TOPMOST, Form1.Left / 15, Form1.Top / 15, Form1.Width / 15, Form1.Height / 15, SWP_NOACTIVATE Or SWP_SHOWWINDOW
    Else
      SetWindowPos Form1.hwnd, HWND_NOTOPMOST, Form1.Left / 15, Form1.Top / 15, Form1.Width / 15, Form1.Height / 15, SWP_NOACTIVATE Or SWP_SHOWWINDOW
    End If
    End Sub
      

    展开全文
  • VB函数参数的使用Byval、Byref 在上位机开发过程中使用VB.net开发的,调用c写得dll,传入参数char*,使用Byval stringBuilder;传入参数const char* Byval string VB的Byref是引用的形式,但是在c库中无法使用 待测...

    VB函数参数的使用Byval、Byref

    在上位机开发过程中使用VB.net开发的,调用c写得dll,传入参数char*,使用Byval stringBuilder;传入参数const char* Byval string
    VB的Byref是引用的形式,但是在c库中无法使用
    待测问题:之前有遇到2017的库不能被正确传入char*参数,怀疑是字符编码,即ANSI和Unicode导致的

    展开全文
  • 1、请问如何用vb调用rar压缩... 首先,你要装Winrar 要把整个用法都写出来也是挺长的(参阅C:\Program Files\Winrar\Rar.txt 47,855 字节来讲RAR的命令行) 简单说 Const WinRAR = "C:\Program Files\Winrar\" 'winrar
  • VC中SPLIT函数的构造如下:String2Array(sInputFormat, m_arrType, ;); int String2Array(const CString& s, CStringArray &sa, char chSplitter) { int n
  • VB随机字母的函数

    千次阅读 2012-05-08 08:37:49
    Function RandABC(N As Long, Optional Model As Long = 1) As String ''N是你想要得到字符串的长度 ''Model是你想得到大写还是小写字母,1--混合大小...Const StrHunhe = "ABCDEFGHIJKLMNOPQRSTUVWXYZa
  • VB 断开指定进程网络连接函数,通过指定进程名字,断开该进程的网络连接。  Private Const PROCESS_QUERY_INFORMATION = 1024Private Const PROCESS_VM_READ = 16Private Const MAX_PATH = 256Private Const...
  • 定义函数:char * strtok(char *s, const char *delim); 函数说明:strtok()用来将字符串分割成一个个片段。参数s 指向欲分割的字符串,参数delim 则为分割字符串,当strtok()在参数s 的字符串中发现到参数delim 的...
  • VB字符串表达式计算函数.

    千次阅读 2008-10-10 22:11:00
    这是一个VB6.0的字符串表达式计算函数. Private Function EvaluateExpr(ByVal expr As String) As Single Const PREC_NONE = 11 Const PREC_UNARY = 10 Const PREC_POWER = 9 Const 
  • Private Const WM_COMMAND As Long = &H111 Private Sub Command1_Click() Dim h1 As Long, h2 As Long, id As Long h1 = FindWindow(vbNullString, "Windows XP Professional - VMware Workstation") ...
  • VB 字符串MD5加密函数

    2013-02-23 07:14:38
    Private Const BITS_TO_A_BYTE = 8Private Const BYTES_TO_A_WORD = 4Private Const BITS_TO_A_WORD = 32Private m_lOnBits(30)Private m_l2Power(30)Dim Md5OLDPublic Enum MD5Type MD5_32 = 32 ...
  • VB】加密/解密函数

    2009-07-03 13:31:00
    对于连接字符串以及一些比较重要的信息需要加密的时候,用下面的函数是个不错的方法。...CodeFunctioncipher(stextAsString)‘加密程序Constmin_asc=32Constmax_asc=126Constnum_asc=max_asc-min_asc+1...
  • 算法已经在Excel中实现,但VB中缺了两个数学函数,标准正态累积分布NormSDist及其反函数NormSInv,一番搜索,折腾出近似算法如下,精度高于10E-7。Function NormSDist(ByVal a As Double) As Double'网上找的多有bug...
  • Private Const MAX_PATH = 260 Private Const FILE_ATTRIBUTE_DIRECTORY = &H10 Private Type FILETIME  dwLowDateTime As Long  dwHighDateTime As Long End Type Private Type WIN32_FIND_DAT
  • Public Declare Function RegisterHotKey Lib "user32" (ByVal hWnd As Long, ByVal id As Long, ByVal fsModifiers As Long, ...Public Const WM_HOTKEY = &H312 Public Const GWL_WNDPROC = (-4) Public p As Long
  • 讲以下代码放入模块中,便... ###########################################################################Global Const SQL_NULL_HANDLE = 0Global Const SQL_HANDLE_ENV = 1Global Const SQL_HANDLE_DBC = 2Glob
  • VB codeOption Explicit'Example Name:Create Font'used with fnWeightConst FW_DONTCARE = 0Const FW_THIN = 100Const FW_EXTRALIGHT = 200Const FW_LIGHT = 300Const FW_NORMAL = 400Const FW_MEDIUM = 500Const F...
  • 人民币大写转化函数VB.NET版)

    千次阅读 2005-06-13 11:26:00
    看了二十四画生的Blog的大小写金额转换函数,自己也对照着写了个VB.NET的,然后用类封装了一下。 Public Class Currency Inherits Object Private Const CST_CAPSTR_TAIL As String = "整" Private Const CST_...
  • VB里,所有API函数、所有常数,都需要用户声明。 ``` Module Module1 Const SW_SHOWNORMAL = 1 Const SW_SHOW = 5 Const SW_SHOWMAXIMIZED = 3 Const SW_SHOWDEFAULT = 10 Public Const WM_...
  • フォームの移動を捕捉用 Public Const WM_SYSCOMMAND As Integer = &H112 Public Const SC_MOVE As Integer = &HF010 Public Const SC_MASK As Integer = &HFFF0 WndProc メソッドをオーバーライドする 
  • const模块:数据库访问常量Public Const SQL_C_CHAR As Long = 1Public Const SQL_COLUMN_LABEL As Long = 18Public Const SQL_DROP As Long = 1Public Const SQL_ERROR As Long = -1Public Const SQL_NO_DATA_FO
  • VB VBA ASP 可通用的基于Base64进行加密和解密的函数可用于Access VBA 以及 Excel VBA对字符串 数据甚至文本文件进行加密和解密,以保证您数据的安全。先创建一个模块,在模块中添加如下代码OPTION EXPLICITconst ...
  • //不支持CompareMethod参数int instr(const char* str, const char* find, int pos=0){ int n=strlen(str); int m=strlen(find); int i=pos; int j; for (i=pos; i for (j=0; j if (st
  • 自定义常量格式:对象浏览器Const ~ =~ 例如Const pi = 3.1415926(圆周率)  变量 Declare 变量名 As 类型 Declare:Dim(自动变量)、Static(静态变量及数组变量)、Redim、Public或者...
  • 满意答案khqqup2014.05.18采纳率:55%等级:8已帮助:313人获取文本行数函数Const WM_USER = &H400Const EM_GETLINECOUNT = WM_USER + 10#If Win32 ThenPrivate Declare Function SendMessage Lib "user32" _...
  • VB结束指定进程代码

    2013-08-02 09:22:42
    vb 中止 指定进程 '查找进程函数 Private Const MAX_PATH = 260 Private Type PROCESSENTRY32 dwSize As Long cntUsage As Long th32ProcessID As Long th32DefaultHeapID As Long th32ModuleID As Long ...
  • 展开全部把以下这些加在VB的BAS中,然后调用ACADRun这个函数就可以了。Option Explicit'Reg Main ItemPublic Const HKEY_CLASSES_ROOT& = &H80000000Public Const HKEY_CURRENT_USER& = &H80000001...
  • VB_窗体透明

    2008-08-08 11:04:00
    我们知道VB没有Delphi的直接可以改变透明度的属性,那么就需要使用API来实现了也~Private Const LWA_ALPHA = Private Const LWA_COLORKEY = Private Const GWL_EXSTYLE = -20Private Const WS_EX_...

空空如也

空空如也

1 2 3 4 5 6
收藏数 113
精华内容 45
关键字:

vbconst函数