Renaming Developer Studio Toolbars by VB Hooks
-
Borrowing heavily from Nick Hodapp's original C code: LRESULT CALLBACK FindToolbarProc(int nCode, WPARAM wParam, LPARAM lParam) { // watch window creation: if (nCode == HCBT_CREATEWND) { CBT_CREATEWND* pcw = (CBT_CREATEWND*)lParam; // watch for toolbar creation, set toolbar name if (pcw->lpcs->lpszName && 0 != strstr(pcw->lpcs->lpszName, "Toolbar")) { strcpy((char*)pcw->lpcs->lpszName, "NukeNCB"); } } return CallNextHookEx(g_hkCBT, nCode, wParam, lParam); } I was hoping to translate this into a VB hook... this is what I have so far... Public Function FindToolbarProc(ByVal ncode As Integer, ByVal wParam As Long, ByVal lParam As Long) As Long Dim tCREATESTRUCT As CREATESTRUCT Dim tCBT_CREATEWND As CBT_CREATEWND Dim ptr As Long Dim sStr As String * 8 'If a keystroke is received. If ncode = HCBT_CREATEWND Then Debug.Print "1.in!>>>>>" 'ptr.lpcs = lParam 'CreateFromPointer (lParam) 'Call CopyMemoryCBT_CreateWnd(mCBT_CREATEWND, lParam, LenB(mCBT_CREATEWND)) 'SetWindowText wParam, "ASDF" Debug.Print "wParam=" & wParam Debug.Print "lParam=" & lParam ptr = VarPtr(tCBT_CREATEWND) Call MoveMemory(ByVal ptr, ByVal lParam, Len(tCBT_CREATEWND)) Debug.Print "CBT_CREATEWND.lpcs=" & tCBT_CREATEWND.lpcs Debug.Print "CBT_CREATEWND.hwnd=" & tCBT_CREATEWND.hWndInsertAfter Call MoveMemory(mCREATESTRUCT, ByVal tCBT_CREATEWND.lpcs, LenB(mCREATESTRUCT)) Debug.Print "mCREATESTRUCT=" & mCREATESTRUCT.lpszClass Debug.Print "mCREATESTRUCT=" & mCREATESTRUCT.lpszName Debug.Print "mCREATESTRUCT=" & mCREATESTRUCT.Style Call MoveMemory(sStr, mCREATESTRUCT.lpszName, 10) End If 'Pass the keystroke on to the primary program and pick up the next hook for processing. FindToolbarProc = CallNextHookEx(gLngWindowHook, ncode, wParam, lParam) End Function Only problem is that the MoveMemory (AKA RTLMOVEMEMORY) command seems to be returning erronous data. Any suggestions?