|
When working on a project with one EXE target and multiple DLL targets, I often have the need to use the same icons amongst the different targets. For example if Tree Views need the same icons, rather than including them in the resources of each target, I do the following.
In the HPP section of the secondary target I add:
#include "d:\projects\mainExeProject\release\wres.h"
#undef WRes_h_included
The first line makes the resources of the main project known. The second allows Power++ to include the wres.h file for the second target.
Then when I need resource, for example a resource called ICON_SHARED, I code as follws:
WModuleHandle ModHandle; rc = imageList->Add(WIcon(WResourceID(ICON_SHARED),ModHandle));
WModule thisMod;
ModHandle = thisMod.GetHandle();
Using the Module Handle I can obtain any resource contained in the executable.
Background : What is the authenticated version of Sybase SQLAnywhere? The authenticated is a full featured version of the database that requires that an application be authenticated to do any write activity to the database. This is a good security feature since it prevents end users from altering the database with 3rd party tools such as MS Query.
Steps I used to authenticate an application:
Details and issues:
Where to place the calls DBAuthInit() and DBAuthFini()
My application opens the database transaction object on the main form. (Note: the transaction object is opened prior to the create event handler on the main form). Thus, to assure the call was made prior to SQL activity I placed the call in the ApplicationClass Start handler . I used the function call GetModuleHandle(NULL) to get the application handle. (Note: Powersoft tech support was of no help when asking where the best location to place the calls and how to get the handle of the application.)
WBool ApplicationClass::StartHandler( WObject *, WStartEventData
*event )
{
HANDLE hInMain;
hInMain = GetModuleHandle(NULL);
if (DBAuthInit( (unsigned int) hInMain) != AUTHERR_SUCCESS)
{
WMessageBox::Info( NULL, "DBAUTH", "Authentication
Failed" );
}
event->abortRun = FALSE;
event->exitCode = 0;
return FALSE;
}
Since I placed the init call in the start handler I figured It would be reasonable to place the fini call in the end handler.
WBool ApplicationClass::EndHandler( WObject *, WEndEventData *event
)
{
DBAuthFini();
return FALSE;
}
How to get the application to compile:
When I initially went to compile the application I received an error on (long)GetCurrentProcessId() which is in appsrc.c. Powersoft said that there is a bug in power++ on how it auto generates the make file (wxt). The work around is to edit the .wxt file and locate where the "WCC386" switches are and delete the -zv switch.
Other notes: Powersoft tech support said that it would not be possible to use the automatic connection option on the transaction object property sheet when using the authenticated version. I had no problem using this option.
I asked Powersoft why they did not include an authenticated check box in the transaction property sheet to simplify this process. (Check appropriate box and include supplied files in the project) I received the response that the authenticated version was cheaper thus the developers should have to go through more trouble using it.