Getting Started Common Acronyms FAQ Forum Help Forum Tips FTP Site Helpful Guidelines Product Community Directory SELECTsupport
#1 Unfortunately there is no public api for that.
#2 You should handle WM_COMMAND message. Like:
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
ON_COMMAND(ID_FILE_OPEN, OnFileOpen) END_MESSAGE_MAP()
I finally got the tool buttons to show up in the ProjectWise Explorer, but there are still a few issues I need to work through.
#1: I want to put the toolbar buttons on the 'trays' that I see in PW Explorer. For instance, there is a "Standard" toolbar that has various document actions on it. You can move this tray around or remove it from the toolbar area. This functionality is how I want my custom toolbar to work.
#2: How do I assign actions to the buttons, so that when the button is clicked it runs my custom code?
Here the code that I have working so far:
void CreateToolbar() { HMODULE hmodBitmapInstance; HWND hwndToolbarInstance = NULL; HWND hwndProjectWise; HWND hwndCurrentWindow = NULL; CString csStringTable = L"awomsg"; LONG lngButtonNames[1]; LONG lngStyles[1];
AFX_MANAGE_STATE(AfxGetStaticModuleState());
lngButtonNames[0] = 101; lngStyles[0] = MAKELONG(BTNS_BUTTON, TBSTATE_ENABLED);
hwndProjectWise = aaApi_GetOwnerWindow(NULL, &hwndCurrentWindow); hwndCurrentWindow = NULL; hwndCurrentWindow = FindWindowEx(hwndProjectWise, hwndCurrentWindow, NULL, NULL); //This is getting the toolbar window area. hwndCurrentWindow = FindWindowEx(hwndProjectWise, hwndCurrentWindow, NULL, NULL);
hmodBitmapInstance = GetModuleHandle(L"PWBVBatchPlot.dll");
hwndToolbarInstance = aaApi_CreateToolBar(hwndCurrentWindow, AATOOLBAR_TOP | AATOOLBAR_NOAUTOSIZE, ID_TOOLBAR, hmodBitmapInstance, IDR_TOOLBAR1, 0, csStringTable, lngButtonNames, lngStyles, 1);
aaApi_UpdateToolBarButtons(hwndToolbarInstance, 0); }
Now that you are supplying a valid string table resource filename, is the error message ("Cannot open resource file") still the same ? Can you provide a small sample project that illustrates the problem ?
Also, you might consider calling AfxFindResourceHandle to obtain the resource handle, instead of passing the hmodBitmapInstance handle directly. For example:
aaApi_CreateToolBar2 (hwndProjectWise, AABAR_TOP, ID_TOOLBAR, AfxFindResourceHandle (MAKEINTRESOURCE(IDR_MYTOOLBAR_ID), RT_TOOLBAR), AfxFindResourceHandle (MAKEINTRESOURCE(IDR_MYTOOLBAR_ID), RT_BITMAP), IDR_MYTOOLBAR_ID, AfxFindResourceHandle(MAKEINTRESOURCE(IDR_HOTLIST), RT_BITMAP), IDR_HOTLIST, NULL, NULL, NULL, 0);
Note that this assumes your DLL is built as an MFC Extension DLL.
HTH
Mike
I put this code into my solution, but I still can't create a custom toolbar.
Here is the code I tried:
===========================================================================
HWND hwndProjectWise; LONG lngStyles[] = {0}; LONG lngButtonNames[] = {IDS_TOOLBARSTRING};
hwndProjectWise = FindWindow(NULL, L" ProjectWise Explorer V8i"); hmodBitmapInstance = GetModuleHandle(L"PWBVBatchPlot.dll");
HSTBL hstblStringTableHandle; CString csStringTable = L"awomsg"; hstblStringTableHandle = aaApi_GetStringTableHandle(csStringTable);
hwndToolbarInstance = aaApi_CreateToolBar(hwndProjectWise, AABAR_TOP, ID_TOOLBAR, modBitmapInstance, IDB_BITMAP1, IDB_BITMAP1, csStringTable, lngButtonNames, lngStyles, 1);
"awomsg" is a resource file that already exists in "C:\program files\Bentley\ProjectWise\rsrc\".
good question. I don't see where you indentify the resource file to load either. is there another function to load the resource file?
This may help:
aaApi_GetStringTableHandle HSTBL AAAPI aaApi_GetStringTableHandle ( LPCWSTR lpctstrTable /* i String Table Name */ ); Description
This function retrieves the string table handle by the given string table name. If the specified table content is not loaded in the calling thread, it will be loaded by this function. Otherwise the handle of an existing table will be returned. The table pointed by the handle contains strings for particular locale and it will be reloaded on first string request after the current locale setting has changed. Note that the returned handle differs from the handle returned by the same function with the same base name called from another thread.
The function above has an example of how to use it in the help listing.
Has anyone created custom toolbars in ProjectWise explorer using the PW SDK? I am looking at the API functions aaApi_CreateToolBar and aaApi_CreateToolBar2, but I'm having trouble figuring out what to use for the parameter list. Here's what my code looks like...
============================================== //In my resource file I have declared the following: Bitmaps |-- IDB_BITMAP1 (This is a 16x16 bitmap) String Table |-- IDS_TOOLBARSTRING 1006 Button1
hwndToolbarInstance = aaApi_CreateToolBar(hwndProjectWise, AABAR_TOP, ID_TOOLBAR, hmodBitmapInstance, IDB_BITMAP1, IDB_BITMAP1, L"String Table", lngButtonNames, lngStyles, 1);
===============================================
This code is returning "Cannot open resource file" when I call aaApi_GetLastErrorDetail().
I'm quite sure that my 6th parameter (Hot List ID) is incorrect, but I'm not sure what this parameter pertains to. Any help or advice is much appreciated.