在vb中有好長的**來實現,在.net中只一句 [窗體].topmost=
true
就能搞定。但在vb6.0中還要用啊。以下是源**。
模組部分通用宣告
public
declare
function 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) as
long
'以上為api函式宣告
public
const hwnd_topmost = -1
public
const swp_nomove =
public
const swp_nosize =
public
const swp_framechanged =
'the frame changed: send wm_nccalcsize
public
const swp_drawframe = swp_framechanged
'以上為程式中用到的常量
public
const hwnd_bottom = 1
public
const hwnd_broadcast = &hffff
public
const hwnd_desktop = 0
public
const hwnd_notopmost = -2
public
const hwnd_top = 0
public
const swp_hidewindow =
public
const swp_noactivate =
public
const swp_nocopybits =
public
const swp_noownerzorder =
'don't do owner z ordering
public
const swp_noredraw =
public
const swp_noreposition = swp_noownerzorder
public
const swp_nozorder =
public
const swp_showwindow =
'以上常量宣告在程式中沒有使用
'可以試著在呼叫setwindowpos函式時使用這些常量或它們的組合
'得到其他效果
public
const flags = swp_drawframe or swp_nomove or swp_nosize
窗體部分,畫乙個checkbox,click事件如下:
private
sub check1_click()
dim res as
long
if check1.value = 1 then
res = setwindowpos(me.hwnd, hwnd_topmost, _
0, 0, 0, 0, flags)
else
res = setwindowpos(me.hwnd, hwnd_notopmost, _
0, 0, 0, 0, flags)
endif
endsub
ok。
指標懸掛問題
為了說明什麼是指標懸掛問題,讓我們考慮下面使用簡單字串類string的程式例子 include string.h class string string void main 在上列程式中,我們沒有為string類過載賦值運算子,因此,賦值表示式 s1 s2 是使用預設的賦值運算子完成s2對s1的賦值...
懸掛畫圓 C
include iom16v.h include math.h include macros.h include delayms.h include 液晶顯示模組.c include 148編碼鍵盤.c define lx 55 x軸總長度 cm define ly 60 y軸總長度 cm defi...
懸掛指標問題例項
今天在寫 的時候遇到乙個問題,當然本身我也是寫乙個小的例子測試記憶體的分配和釋放的問題,一下子碰到了這個懸掛指標的問題 錯誤 include include int main void int b int malloc sizeof int b p free b b null return 0 這段...