ab.com コミュニティ https://www.activebasic.com/forum/ |
|
Static https://www.activebasic.com/forum/viewtopic.php?t=4604 |
ページ 1 / 1 |
作成者: | TISAproject [ 2016年10月31日(月) 17:18 ] |
記事の件名: | Static |
コード: '----------------------------------------------------------------------------- ' イベント プロシージャ '----------------------------------------------------------------------------- ' このファイルには、ウィンドウ [CPUUSESWATCHER] に関するイベントをコーディングします。 ' ウィンドウ ハンドル: hCPUUSESWATCHER ' TODO: この位置にグローバルな変数、構造体、定数、関数を定義します。 Declare Function PdhOpenQuery Lib "pdh" Alias "PdhVbOpenQuery" ( _ ByRef QueryHandle As long) As long Declare Function PdhAddCounter Lib "pdh" Alias "PdhVbAddCounter" ( _ ByVal QueryHandle As long, _ ByVal CounterPath As long, _ ByRef CounterHandle As long) As long Declare Function PdhCollectQueryData Lib "pdh" ( _ ByVal QueryHandle As long) As long Declare Function PdhGetDoubleCounterValue Lib "pdh" _ Alias "PdhVbGetDoubleCounterValue" ( _ ByVal CounterHandle As long, _ ByRef CounterStatus As long) As Double Declare Function PdhCloseQuery Lib "pdh" ( _ ByVal QueryHandle As long) As long 'CPU使用率を返す(%) Function GetCPUutilization(wait As long) As long Dim hQuery As long Dim hCounter As long Dim CounterStatus As long PdhOpenQuery(hQuery) PdhAddCounter( hQuery, "\Processor(_Total)\% Processor Time", hCounter) PdhCollectQueryData( hQuery) Sleep(wait) PdhCollectQueryData( hQuery) GetCPUutilization = PdhGetDoubleCounterValue(hCounter, CounterStatus) PdhCloseQuery( hQuery) End Function Dim Maintittle As long Dim cnt As long cnt = 100 Maintittle = GetCPUutilization(1000) SetWindowText(GetDlgItem(hCPUUSESWATCHER,Static2), Maintittle ) Dim DefEditProc As Long Dim Onthefile As string Dim Onput As string Dim strURL As string Dim Option1 As long Function DropEditProc(hWnd As HWND, message As DWORD, wParam As DWORD, lParam As DWORD) As DWORD Select Case message Case WM_DROPFILES Dim hDrop As HDROP Dim FileName[MAX_PATH] As Byte Dim FileName2 As string hDrop=wParam As HDROP 'ドロップされたファイル名を取得 DragQueryFile(hDrop, 0, FileName, MAX_PATH) Onthefile = FileName SetWindowText(GetDlgItem(hMainWnd,EditBox1), Onthefile ) DragFinish(hDrop) DropEditProc=0 Exit Function End Select DropEditProc=CallWindowProc(DefEditProc As VoidPtr, hWnd, message, wParam, lParam) End Function '----------------------------------------------------------------------------- ' ウィンドウメッセージを処理するためのコールバック関数 Function CPUUSESWATCHERProc(hWnd As HWND, dwMsg As DWord, wParam As WPARAM, lParam As LPARAM) As DWord ' TODO: この位置にウィンドウメッセージを処理するためのコードを記述します。 ' イベントプロシージャの呼び出しを行います。 CPUUSESWATCHERProc=EventCall_CPUUSESWATCHER(hWnd,dwMsg,wParam,lParam) End Function '----------------------------------------------------------------------------- ' ここから下は、イベントプロシージャを記述するための領域になります。 Sub CPUUSESWATCHER_EditBox1_Change() End Subこれでウインドウを画面に出力した時にStatic2にCPU使用率が表示されないんですがどうすればいいでしょう? |
作成者: | たかせ [ 2016年11月09日(水) 19:17 ] |
記事の件名: | Re: Static |
SetWindowTextの2番目のパラメータは確かByte型またはChar型の配列を指定しないと表示されません。 Dim Maintittle As long Dim cnt As long cnt = 100 Maintittle = GetCPUutilization(1000) SetWindowText(GetDlgItem(hCPUUSESWATCHER,Static2), Maintittle ) ↓下記の様にしてください。 Dim Maintittle As long Dim cnt As long Dim Text[127] As Byte 'またはDim Text[127] As Char cnt = 100 Maintittle = GetCPUutilization(1000) wsprintf(Text,"%d",Maintittle) SetWindowText(GetDlgItem(hCPUUSESWATCHER,Static2), Text ) |
ページ 1 / 1 | 全ての表示時間は UTC+09:00 です |
Powered by phpBB® Forum Software © phpBB Limited https://www.phpbb.com/ |