ab.com コミュニティ https://www.activebasic.com/forum/ |
|
既存のウィンドウに対するクラス https://www.activebasic.com/forum/viewtopic.php?t=108 |
ページ 1 / 1 |
作成者: | 7 [ 2005年6月12日(日) 13:43 ] |
記事の件名: | 既存のウィンドウに対するクラス |
RADツールで作ったウィンドウに対する関数を集めただけであってウィンドウを一から作るクラスではありません。 コード: Class CWindowBase Protected c_hWnd As HWND Public 'ウィンドウが存在するか判定するように変更 Sub CWindowBase(ByVal hWnd As HWND) c_hWnd=hWnd If isWindow()=FALSE Then'+ c_hWnd=NULL'+ End If'+ End Sub Sub ~CWindowBase() c_hWnd=NULL End Sub 'ウィンドウハンドルを返すだけ、に変更 Function getHandle() As HWND ' If isWindow() Then getHandle=c_hWnd ' Else ' getHandle=FALSE ' End If End Function Function isWindow() As Long isWindow=IsWindow(c_hWnd) End Function End Class コード: Dim wndbase As CWindowBase(hMainWnd) 'hMainWndが存在するならTRUE,しないならFALSE wndbase.isWindow() 'hMainWndが存在するならハンドル、しないならFASE wndbase.getHandle()ウィンドウハンドルをコンストラクタで設定、デストラクタで破棄しているんですが、別に設定・破棄の関数を用意した方が良いんでしょうか? 一応、link()関数とunlink()関数を考えてはいるんですが。 CWindowBaseを継承していって以下のようにしようと思っているんですが、まだCWindowBaseしか出来ていません…。 コード: CWindowBase | CWindowBaseEx ____|____ | | CWindow CControl _________|____________________________________ | | | | | CStatic CEditBox CCommandButton CCheckBox? CRadioButton? ____|_______ | | CCheckBox? CRadioButton? | CRadioButton?整形するのにcodeを使いました…。 |
作成者: | 7 [ 2005年7月09日(土) 12:00 ] |
記事の件名: | |
コード: Class CWindowBaseEx Inherits CWindowBase Protected Sub setString(ByVal lpString As BytePtr) SetWindowText(c_hWnd,lpString) End Sub Function getString() As BytePtr Dim len As Long len=length()+1 getString=calloc(len) GetWindowText(c_hWnd,getString,len) End Function Public Sub CWindowBaseEx(ByVal hWnd As HWND) CWindowBase(hWnd) End Sub '-----ウィンドウメッセージ----- Function sendMsg(ByVal wMsg As DWord,ByVal wParam As DWord,ByVal lParam As DWord) As Long sendMsg=SendMessage(c_hWnd,wMsg,wParam,lParam) End Function Function postMsg(ByVal wMsg As DWord,ByVal wParam As DWord,ByVal lParam As DWord) As Long postMsg=PostMessage(c_hWnd,wMsg,wParam,lParam) End Function '-----ウィンドウスタイル----- Function setStyle(ByVal newLong As Long) As Long setStyle=SetWindowLong(c_hWnd,GWL_STYLE,newLong) End Function Function getStyle() As Long getStyle=GetWindowLong(c_hWnd,GWL_STYLE) End Function Function setStyleEx(ByVal newLong As Long) As Long setStyleEx=SetWindowLong(c_hWnd,GWL_EXSTYLE,newLong) End Function Function getStyleEx() As Long getStyleEx=GetWindowLong(c_hWnd,GWL_EXSTYLE) End Function '-----ウィンドウポジション----- Sub setPos(ByVal x As Long,ByVal y As Long) SetWindowPos(c_hWnd,NULL,x,y,NULL,NULL,SWP_NOSIZE) End Sub Sub getPos(ByRef lpPoint As POINTAPI) Dim tmpRect As RECT GetWindowRect(c_hWnd,tmpRect) lpPoint.x=tmpRect.left lpPoint.y=tmpRect.top End Sub Sub setX(ByVal x As Long) setPos(x,getY()) End Sub Function getX() As Long Dim tmpPoint As POINTAPI getPos(tmpPoint) getX=tmpPoint.x End Function Sub setY(ByVal y As Long) setPos(getX(),y) End Sub Function getY() As Long Dim tmpPoint As POINTAPI getPos(tmpPoint) getY=tmpPoint.y End Function '-----ウィンドウサイズ----- Sub setSize(ByVal width As Long,ByVal height As Long) SetWindowPos(c_hWnd,NULL,NULL,NULL,width,height,SWP_NOMOVE) End Sub Sub getSize(ByRef lpSize As SIZE) Dim tmpRect As RECT GetWindowRect(c_hWnd,tmpRect) lpSize.cx=tmpRect.right-tmpRect.left lpSize.cy=tmpRect.bottom-tmpRect.top End Sub Sub setWidth(ByVal width As Long) setSize(width,getHeight()) End Sub Function getWidth() As Long Dim tmpSize As SIZE getSize(tmpSize) getWidth=tmpSize.cx End Function Sub setHeight(ByVal height As Long) setSize(getWidth(),height) End Sub Function getHeight() As Long Dim tmpSize As SIZE getSize(tmpSize) getHeight=tmpSize.cy End Function '-------------------- Function length() As Long length=GetWindowTextLength(c_hWnd) End Function Sub setFocus() SetFocus(c_hWnd) End Sub Sub invalidate(ByRef lpRect As RECT,ByVal bErase As Long) InvalidateRect(c_hWnd,lpRect,bErase) End Sub 'TRUE:ウィンドウを表示 'FALSE:ウィンドウを非表示 Sub show(ByVal bShow As Long) If bShow Then ShowWindow(c_hWnd,SW_SHOW) Else ShowWindow(c_hWnd,SW_HIDE) End If End Sub Function isShowing() As Long isShowing=IsWindowVisible(c_hWnd) End Function 'TRUE:ウィンドウを有効 'FALSE:ウィンドウを無効 Sub enable(ByVal bEnable As Long) EnableWindow(c_hWnd,bEnable) End Sub Function isEnabled() As Long isEnabled=IsWindowEnabled(c_hWnd) End Function Sub update() UpdateWindow(c_hWnd) End Sub 'TRUE:ウィンドウの描写を無効 'FALSE:ウィンドウの描写を有効 Sub lockUpdate(ByVal bLock As Long) If bLock Then LockWindowUpdate(c_hWnd) Else LockWindowUpdate(NULL) End If End Sub End Class |
作成者: | イグトランス [ 2005年7月09日(土) 12:05 ] |
記事の件名: | Re: 既存のウィンドウに対するクラス |
なんだかこれ良さそうですね。完成したらなかなか便利に使えそうです。 ところでgetHandleではisWindow()で判定を行っていますが、私はコンストラクタでisWindow()が偽ならc_hWndをNULLにして、getHandleは単にc_hWndを返すだけとするほうがいいのではと思うのですがどうでしょうか。 あと、CWindowBaseExにgetText/setTextがあるほうが便利だと思います。 Function getText() As String Dim Length As Long Length = GetWindowTextLength(c_hWnd) getText= ZeroString(Length) GetWindowText(c_hWnd, StrPtr(getText), Length + 1) End Function |
作成者: | まけイヌ [ 2005年7月19日(火) 23:01 ] |
記事の件名: | 更に要望?? |
ウィンドウ周りなら、単純なサイズ変更や移動などが出来ると便利ですね。 あと、親ウィンドウを視野に入れるならセンタリング機能とか。 サイズ変更・移動 .. SetWindowPos関数(API) センタリング .. SetWindowPos関数(API)とGetWindowRect関数(API)の組み合わせ で、意外と簡単に実装できると思います。 ※そのくせよく使うので(^^; ついで、リージョンなんかも弄れると面白いかも。 せっかくクラス化するんですから、 指定したポリゴン(POINTAPIハンドル)から内部リージョンを作り、 そのリージョンを元にウィンドウの形を切れると デスクトップマスコットなんかも簡単に作れると思います。 ※こいつは少し難易度が高いですが.. 後はInvalidateRect関数(API)の省略。 cw.Invalidate()とかするだけで再描画してくれると便利ですかね。 ※よくタイプミスするんです、InvalidateRect..(^^;;; ※クラス化すればメンバなので楽に取り出せます 余力があればご参考ください。 |
作成者: | 7 [ 2005年7月25日(月) 00:48 ] |
記事の件名: | |
パソコンがクラッシュしてしまい修理に出してました…。 イグトランスさん コンストラクタでisWindow()を使って判定する方がスリムで良いですね。 setText()/getText()は、CWindowBaseExを拡張してCWindow,CControlに派生する訳なんですが、CWindowにはsetTitle()/getTitle()、CControlにはsetText()/getText()を追加する予定でCWindowBaseExには入れないつもりです。 まけイヌさん ウィンドウのサイズ・ポジション変更、センタリングはプログラミング忘れてました…。 他にもCWindowBaseExに忘れていた関数が有ったので少しずつでも追加します。 リージョンはなんでしょう…。リージョンについて無知なので、なるべく触りたくないんですが…リージョンはリージョンでクラス化するとか…? そしたら、CRegionかCWindowRgnという感じでしょうね。 |
作成者: | イグトランス [ 2005年7月25日(月) 08:14 ] |
記事の件名: | |
> イグトランスさん > コンストラクタでisWindow()を使って判定する方がスリムで良いですね。 > setText()/getText()は、CWindowBaseExを拡張してCWindow,CControlに派生する訳なんですが、CWindowにはsetTitle()/getTitle()、CControlにはsetText()/getText()を追加する予定でCWindowBaseExには入れないつもりです。 そういうことですか。わかりました。ならProtectedメンバにでも入れたらでしょう。どうせやることは同じなんですから。(しつこいようですいません) |
作成者: | 7 [ 2005年7月25日(月) 12:47 ] |
記事の件名: | |
コード: Class CWindow Inherits CWindowBaseEx Public Sub CWindow(ByVal hWnd As HWND) CWindowBaseEx(hWnd) End Sub Sub setTitle(ByVal lpTitle As BytePtr) setString(lpTitle) End Sub Function getTitle() As BytePtr getTitle=getString() End Function Sub center() Dim tmpRect As RECT GetWindowRect(GetDesktopWindow(),tmpRect) setPos( (tmpRect.right/2)-(getWidth()/2) , (tmpRect.bottom/2)-(getHeight()/2) ) End Sub Sub flash() FlashWindow(c_hWnd,TRUE) End Sub Sub open() ShowWindow(c_hWnd,SW_SHOWNORMAL) End Sub Sub icon() ShowWindow(c_hWnd,SW_MINIMIZE) End Sub Function isIconic() As Long isIconic=IsIconic(c_hWnd) End Function Sub zoom() ShowWindow(c_hWnd,SW_MAXIMIZE) End Sub Function isZoomed() As Long isZoomed=IsZoomed(c_hWnd) End Function Sub toFront() SetWindowPos(c_hWnd,HWND_TOP,NULL,NULL,NULL,NULL,SWP_NOMOVE or SWP_NOSIZE) End Sub Sub toBack() SetWindowPos(c_hWnd,HWND_BOTTOM,NULL,NULL,NULL,NULL,SWP_NOMOVE or SWP_NOSIZE) End Sub End Class |
作成者: | 7 [ 2005年9月12日(月) 21:30 ] |
記事の件名: | |
書き直しで、しかも長くてすみません…(汗 そのうちCWindowやCControlも投稿します。 コード: /* CWindowBase Protected c_hWnd As HWND Public '----------Window Initialize Method---------- Sub CWindowBase(ByVal hWnd As HWND) Sub ~CWindowBase() '----------Window State Method---------- Function getHandle() As HWND Function isWindow() As Long */ Class CWindowBase Protected c_hWnd As HWND Public '----------Window Initialize Method---------- Sub CWindowBase(ByVal hWnd As HWND) c_hWnd=hWnd If isWindow()=FALSE Then c_hWnd=NULL End If End Sub Sub ~CWindowBase() c_hWnd=NULL End Sub '----------Window State Method---------- Function getHandle() As HWND getHandle=c_hWnd End Function Function isWindow() As Long isWindow=IsWindow(c_hWnd) End Function End Class コード: /* CWindowBaseEx Public '----------Window Initialize Method---------- Sub CWindowBaseEx(ByVal hWnd As HWND) '----------Window Text Method---------- Function getTextLength() As Long '----------Window Font Method---------- Sub setFont(ByVal hFont As HFONT,ByVal bRedraw As Long) Function getFont() As HFONT '----------Window Size Method---------- Sub setSize(ByVal width As Long,ByVal height As Long) Sub getSize(ByRef lpSize As SIZE) Sub setWidth(ByVal width As Long) Function getWidth() As Long Sub setHeight(ByVal height As Long) Function getHeight() As Long '----------Window Rectangle Method---------- Sub getRect(ByRef lpRect As RECT) Sub getClientRect(ByRef lpRect As RECT) '----------Window Position Method---------- Sub setPos(ByVal x As Long,ByVal y As Long) Sub getPos(ByRef lpPoint As POINTAPI) Sub setX(ByVal x As Long) Function getX() As Long Sub setY(ByVal y As Long) Function getY() As Long '----------Window Size And Position Method---------- Sub move(ByVal x As Long,ByVal y As Long,ByVal nWidth As Long,ByVal nHeight As Long,ByVal bRepain As Long) '----------Window State Method---------- Sub enable(ByVal bEnable As Long) Function isEnabled() As Long Function setParent(ByVal hWndNewParent As HWND) As HWND Function getParent() As HWND Function setLong(ByVal nIndex As Long,ByVal NewLong As Long) As Long Function getLong(ByVal nIndex As Long) As Long Function setClassLong(ByVal nIndex As Long,ByVal NewLong As Long) As DWord Function getClassLong(ByVal nIndex As Long) As DWord Sub setFocus() Function getFocus() As HWND Function setCapture() As HWND Function getCapture() As HWND Sub releaseCapture() '----------Window Message Method---------- Function sendMessage(ByVal wMsg As DWord,ByVal wParam As DWord,ByVal lParam As DWord) As Long Function postMessage(ByVal wMsg As DWord,ByVal wParam As DWord,ByVal lParam As DWord) As Long '----------Window Style Method---------- Function setStyle(ByVal newLong As Long) As Long Function getStyle() As Long Function setExStyle(ByVal newLong As Long) As Long Function getExStyle() As Long '----------Window Update And Draw Method---------- Sub show(ByVal bShow As Long) Function isShowing() As Long Function getDC() As HDC Sub releaseDC(ByVal hDC As HDC) Sub setRedraw(ByVal bRedraw As Long) Sub invalidate(ByVal bErase As Long) Sub invalidateRect(ByRef lpRect As RECT,ByVal bErase As Long) Sub update() Sub lockUpdate(ByVal bLock As Long) '----------Window Locate Method---------- Sub toScreen(ByRef lpPoint As POINTAPI) Sub toClient(ByRef lpPoint As POINTAPI) '----------Window Alarm Method---------- Function messageBox(ByVal lpText As BytePtr,ByVal lpCaption As BytePtr,ByVal uType As DWord) As Long Sub messageBeep(ByVal uType As DWord) */ Class CWindowBaseEx Inherits CWindowBase Public '----------Window Initialize Method---------- Sub CWindowBaseEx(ByVal hWnd As HWND) CWindowBase(hWnd) End Sub '----------Window Text Method---------- Function getTextLength() As Long getTextLength=GetWindowTextLength(c_hWnd) End Function '----------Window Font Method---------- Sub setFont(ByVal hFont As HFONT,ByVal bRedraw As Long) sendMessage(WM_SETFONT,hFont As DWord,bRedraw As DWord) End Sub Function getFont() As HFONT getFont=sendMessage(WM_GETFONT,NULL,NULL) As HFONT End Function '----------Window Size Method---------- Sub setSize(ByVal width As Long,ByVal height As Long) SetWindowPos(c_hWnd,NULL,NULL,NULL,width,height,SWP_NOMOVE) End Sub Sub getSize(ByRef lpSize As SIZE) Dim tmpRect As RECT GetWindowRect(c_hWnd,tmpRect) lpSize.cx=tmpRect.right-tmpRect.left lpSize.cy=tmpRect.bottom-tmpRect.top End Sub Sub setWidth(ByVal width As Long) setSize(width,getHeight()) End Sub Function getWidth() As Long Dim tmpSize As SIZE getSize(tmpSize) getWidth=tmpSize.cx End Function Sub setHeight(ByVal height As Long) setSize(getWidth(),height) End Sub Function getHeight() As Long Dim tmpSize As SIZE getSize(tmpSize) getHeight=tmpSize.cy End Function '----------Window Rectangle Method---------- Sub getRect(ByRef lpRect As RECT) GetWindowRect(c_hWnd,lpRect) End Sub Sub getClientRect(ByRef lpRect As RECT) GetClientRect(c_hWnd,lpRect) End Sub '----------Window Position Method---------- Sub setPos(ByVal x As Long,ByVal y As Long) SetWindowPos(c_hWnd,NULL,x,y,NULL,NULL,SWP_NOSIZE) End Sub Sub getPos(ByRef lpPoint As POINTAPI) Dim tmpRect As RECT GetWindowRect(c_hWnd,tmpRect) lpPoint.x=tmpRect.left lpPoint.y=tmpRect.top End Sub Sub setX(ByVal x As Long) setPos(x,getY()) End Sub Function getX() As Long Dim tmpPoint As POINTAPI getPos(tmpPoint) getX=tmpPoint.x End Function Sub setY(ByVal y As Long) setPos(getX(),y) End Sub Function getY() As Long Dim tmpPoint As POINTAPI getPos(tmpPoint) getY=tmpPoint.y End Function '----------Window Size And Position Method---------- Sub move(ByVal x As Long,ByVal y As Long,ByVal nWidth As Long,ByVal nHeight As Long,ByVal bRepain As Long) MoveWindow(c_hWnd,x,y,nWidth,nHeight,bRepain) End Sub '----------Window State Method---------- Sub enable(ByVal bEnable As Long) EnableWindow(This.c_hWnd,bEnable) End Sub Function isEnabled() As Long isEnabled=IsWindowEnabled(c_hWnd) End Function Function setParent(ByVal hWndNewParent As HWND) As HWND setParent=SetParent(c_hWnd,hWndNewParent) End Function Function getParent() As HWND getParent=GetParent(c_hWnd) End Function Function setLong(ByVal nIndex As Long,ByVal NewLong As Long) As Long setLong=SetWindowLong(c_hWnd,nIndex,NewLong) End Function Function getLong(ByVal nIndex As Long) As Long getLong=GetWindowLong(c_hWnd,nIndex) End Function Function setClassLong(ByVal nIndex As Long,ByVal NewLong As Long) As DWord setClassLong=SetClassLong(c_hWnd,nIndex,NewLong) End Function Function getClassLong(ByVal nIndex As Long) As DWord getClassLong=GetClassLong(c_hWnd,nIndex) End Function Sub setFocus() SetFocus(c_hWnd) End Sub Function getFocus() As HWND getFocus=GetFocus() End Function Function setCapture() As HWND setCapture=SetCapture(c_hWnd) End Function Function getCapture() As HWND getCapture=GetCapture() End Function Sub releaseCapture() ReleaseCapture() End Sub '----------Window Message Method---------- Function sendMessage(ByVal wMsg As DWord,ByVal wParam As DWord,ByVal lParam As DWord) As Long sendMessage=SendMessage(c_hWnd,wMsg,wParam,lParam) End Function Function postMessage(ByVal wMsg As DWord,ByVal wParam As DWord,ByVal lParam As DWord) As Long postMessage=PostMessage(c_hWnd,wMsg,wParam,lParam) End Function '----------Window Style Method---------- Function setStyle(ByVal newLong As Long) As Long setStyle=SetWindowLong(c_hWnd,GWL_STYLE,newLong) End Function Function getStyle() As Long getStyle=GetWindowLong(c_hWnd,GWL_STYLE) End Function Function setExStyle(ByVal newLong As Long) As Long setExStyle=SetWindowLong(c_hWnd,GWL_EXSTYLE,newLong) End Function Function getExStyle() As Long getExStyle=GetWindowLong(c_hWnd,GWL_EXSTYLE) End Function '----------Window Update And Draw Method---------- Sub show(ByVal bShow As Long) If bShow Then ShowWindow(c_hWnd,SW_SHOW) Else ShowWindow(c_hWnd,SW_HIDE) End If End Sub Function isShowing() As Long isShowing=IsWindowVisible(c_hWnd) End Function Function getDC() As HDC getDC=GetDC(c_hWnd) End Function Sub releaseDC(ByVal hDC As HDC) ReleaseDC(c_hWnd,hDC) End Sub Sub setRedraw(ByVal bRedraw As Long) sendMessage(WM_SETREDRAW,bRedraw As DWord,NULL) End Sub Sub invalidate(ByVal bErase As Long) invalidateRect(ByVal NULL,bErase) End Sub Sub invalidateRect(ByRef lpRect As RECT,ByVal bErase As Long) InvalidateRect(c_hWnd,lpRect,bErase) End Sub Sub update() UpdateWindow(c_hWnd) End Sub Sub lockUpdate(ByVal bLock As Long) If bLock Then LockWindowUpdate(c_hWnd) Else LockWindowUpdate(NULL) End If End Sub '----------Window Locate Method---------- Sub toScreen(ByRef lpPoint As POINTAPI) ClientToScreen(c_hWnd,lpPoint) End Sub Sub toClient(ByRef lpPoint As POINTAPI) ScreenToClient(c_hWnd,lpPoint) End Sub '----------Window Alarm Method---------- Function messageBox(ByVal lpText As BytePtr,ByVal lpCaption As BytePtr,ByVal uType As DWord) As Long messageBox=MessageBox(c_hWnd,lpText,lpCaption,uType) End Function Sub messageBeep(ByVal uType As DWord) MessageBeep(uType) End Sub End Class |
作成者: | 7 [ 2005年9月16日(金) 18:02 ] |
記事の件名: | |
コード: Declare Function FlashWindowEx Lib "user32" (ByRef pfwi As FLASHWINFO) As Long Const FLASHW_STOP=0 Const FLASHW_CAPTION=1 Const FLASHW_TRAY=2 Const FLASHW_ALL=FLASHW_CAPTION or FLASHW_TRAY Const FLASHW_TIMER=4 Const FLASHW_TIMERNOFG=12 Type FLASHWINFO cbSize As Long hWnd As HWND dwFlags As DWord uCount As Long dwTimeout As DWord End Type /* CWindow Protected c_hWnd As HWND Public '----------Window Initialize Method---------- Sub CWindow(ByVal hWnd As HWND) '----------Window Text Method---------- Sub setTitle(ByVal lpTitle As BytePtr) Function getTitle() As BytePtr '----------Window Icon Method---------- Sub setIcon(ByVal hIcon As HICON,ByVal uType As DWord) Function getIcon(ByVal uType As DWord) As HICON '----------Window Position Method---------- Sub center() '----------Window State Method---------- Sub toTop() Sub toFront() Sub toBack() Sub toBottom() Function isChild(ByVal hWnd As HWND) As Long '----------Window DialogBox Method---------- Function getDlgItem(ByVal nIDDlgItem As Long) As HWND Function sendDlgItemMessage(ByVal nIDDlgItem As Long,ByVal wParam As DWord,ByVal lParam As DWord) As Long Sub setDlgItemText(ByVal nIDDlgItem As Long,ByVal lpString As BytePtr) Function getDlgItemText(ByVal nIDDlgItem As Long,ByVal lpString As BytePtr,ByVal nMaxCount As Long) As Long '----------Window Update And Draw Method---------- Sub open() Sub icon() Function isIconic() As Long Sub zoom() Function isZoomed() As Long '----------Window Alarm Method---------- Function flash(ByVal bInvert As Long) As Long Function flashEx(ByVal dwFlags As DWord,ByVal uCount As Long,ByVal dwTimeout As DWord) As Long '----------Window Timer Method---------- Function setTimer(ByVal nIDEvent As DWord,ByVal nElapse As DWord,ByVal lpTimerFunc As DWord) As DWord Sub killTimer(ByVal nIDEvent As DWord) */ Class CWindow Inherits CWindowBaseEx Public '----------Window Initialize Method---------- Sub CWindow(ByVal hWnd As HWND) CWindowBaseEx(hWnd) End Sub '----------Window Text Method---------- Sub setTitle(ByVal lpTitle As BytePtr) SetWindowText(c_hWnd,lpTitle) End Sub Function getTitle() As BytePtr Dim len As Long len=getTextLength()+1 getTitle=calloc(len) GetWindowText(c_hWnd,getTitle,len) End Function '----------Window Icon Method---------- Sub setIcon(ByVal hIcon As HICON,ByVal uType As DWord) sendMessage(WM_SETICON,uType,hIcon As DWord) End Sub Function getIcon(ByVal bIcon As Long) As HICON If bIcon Then getIcon=sendMessage(WM_GETICON,ICON_BIG,NULL) As HICON Else getIcon=sendMessage(WM_GETICON,ICON_SMALL,NULL) As HICON End If End Function '----------Window Position Method---------- Sub center() Dim tmpRect As RECT GetWindowRect(GetDesktopWindow(),tmpRect) setPos( (tmpRect.right/2)-(getWidth()/2) , (tmpRect.bottom/2)-(getHeight()/2) ) End Sub '----------Window State Method---------- Sub toTop() SetWindowPos(c_hWnd,HWND_TOPMOST,NULL,NULL,NULL,NULL,SWP_NOMOVE or SWP_NOSIZE) End Sub Sub toFront() SetWindowPos(c_hWnd,HWND_TOP,NULL,NULL,NULL,NULL,SWP_NOMOVE or SWP_NOSIZE) End Sub Sub toBack() SetWindowPos(c_hWnd,HWND_BOTTOM,NULL,NULL,NULL,NULL,SWP_NOMOVE or SWP_NOSIZE) End Sub Sub toBottom() SetWindowPos(c_hWnd,HWND_NOTOPMOST,NULL,NULL,NULL,NULL,SWP_NOMOVE or SWP_NOSIZE) End Sub Function isChild(ByVal hWnd As HWND) As Long isChild=IsChild(c_hWnd,hWnd) End Function '----------Window DialogBox Method---------- Function getDlgItem(ByVal nIDDlgItem As Long) As HWND getDlgItem=GetDlgItem(c_hWnd,nIDDlgItem) End Function Function sendDlgItemMessage(ByVal nIDDlgItem As Long,ByVal wParam As DWord,ByVal lParam As DWord) As Long sendDlgItemMessage=SendDlgItemMessage(c_hWnd,nIDDlgItem,wMsg,wParam,lParam) End Function Sub setDlgItemText(ByVal nIDDlgItem As Long,ByVal lpString As BytePtr) SetDlgItemText(c_hWnd,nIDDlgItem,lpString) End Sub Function getDlgItemText(ByVal nIDDlgItem As Long,ByVal lpString As BytePtr,ByVal nMaxCount As Long) As Long getDlgItemText=GetDlgItemText(c_hWnd,nIDDlgItem,lpString,nMaxCount) End Function '----------Window Update And Draw Method---------- Sub open() ShowWindow(c_hWnd,SW_SHOWNORMAL) End Sub Sub icon() ShowWindow(c_hWnd,SW_MINIMIZE) End Sub Function isIconic() As Long isIconic=IsIconic(c_hWnd) End Function Sub zoom() ShowWindow(c_hWnd,SW_MAXIMIZE) End Sub Function isZoomed() As Long isZoomed=IsZoomed(c_hWnd) End Function '----------Window Alarm Method---------- Function flash(ByVal bInvert As Long) As Long flash=FlashWindow(C_hWnd,bInvert) End Function Function flashEx(ByVal dwFlags As DWord,ByVal uCount As Long,ByVal dwTimeout As DWord) As Long Dim pfwi As FLASHWINFO With pfwi .cbSize=SizeOf(FLASHWINFO) .hWnd=c_hWnd .dwFlags=dwFlags .uCount=uCount .dwTimeout=dwTimeout End With flashEx=FlashWindowEx(pfwi) End Function '----------Window Timer Method---------- Function setTimer(ByVal nIDEvent As DWord,ByVal nElapse As DWord,ByVal lpTimerFunc As DWord) As DWord setTimer=SetTimer(c_hWnd,nIDEvent,nElapse,lpTimerFunc) End Function Sub killTimer(ByVal nIDEvent As DWord) KillTimer(c_hWnd,nIDEvent) End Sub End Class コード: /* CControl Protected c_hID As Long Public '----------Window Initialize Method---------- Sub CControl(ByVal hWnd As HWND,ByVal nIDDlgItem As Long) '----------Window Text Method---------- Sub setText(ByVal lpTitle As BytePtr) Function getText() As BytePtr '----------Window State Method---------- Function getID() As Long */ Class CControl Inherits CWindowBaseEx Protected c_hID As Long Public '----------Window Initialize Method---------- Sub CControl(ByVal hWnd As HWND,ByVal nIDDlgItem As Long) CWindowBaseEx(GetDlgItem(hWnd,nIDDlgItem)) c_hID=nIDDlgItem End Sub '----------Window Text Method---------- Sub setText(ByVal lpText As BytePtr) SetWindowText(c_hWnd,lpText) End Sub Function getText() As BytePtr Dim len As Long len=getTextLength()+1 getText=calloc(len) GetWindowText(c_hWnd,getText,len) End Function '----------Window Position Method---------- Sub getPos(ByRef lpPoint As POINTAPI) Dim tmpRect As RECT GetWindowRect(c_hWnd,tmpRect) lpPoint.x=tmpRect.left lpPoint.y=tmpRect.top ScreenToClient(getParent(),lpPoint) End Sub Function getX() As Long Dim tmpPoint As POINTAPI getPos(tmpPoint) getX=tmpPoint.x End Function Function getY() As Long Dim tmpPoint As POINTAPI getPos(tmpPoint) getY=tmpPoint.y End Function '----------Window State Method---------- Function getID() As Long getID=c_hID End Function End Class[/code] |
ページ 1 / 1 | 全ての表示時間は UTC+09:00 です |
Powered by phpBB® Forum Software © phpBB Limited https://www.phpbb.com/ |