[Home][CADCAM][Contents] [Search]

CADCAM

 

Index (59 Tips)

VB (18)
VC (11)
SolidWorks API (2)
ATL (5)
FrontPage (14)
Internet (2)
IIS (2)
Conventions
Windows NT (3)
Office (2)

If you visit this page for the first time, be tolerant because some of the tips indicated here may be due to lack of carefull study of the documentations. However they are helpfull for stressed people like us.

VB

TIP 1 : Keywords: VB, Debug

If you want to debug a VB ActiveX Dll from an external executable you have to switch the project as a server and break in class module. If the activeX is called by an Implements interface which is not OLE Automation you have to install marshalling for it.

TIP  2 : Keywords: VB, Object, New

Objects declared as slots of others with the New attribute are allocated on need only.
Dim LeftWheel as New Wheel

TIP   3 : Keywords: VB, Implements

If implements fails (means is not recognized in the drop down menu) it can be because one the types used in the interface is not yet referenced in the project. Consider referencing stdole2.dll for IUnknown by example. This hould not happen if stdole2.idl is correctly referenced in the idl.

TIP  4 : Keywords: VB, PropertyPage

The method DoChanges is called twice on every Apply

TIP  5 : Keywords: VB, DBGrid

To add a column

  1. Select the control
  2. Popup Menu: choose Edit
  3. Select  the preceding column
  4. Popup Menu: choose Append
  5. Fill the properties with the custom properties button

TIP 6 : Keywords: VB, ConnectAttrFail

Message can be strange. Like this one SetConnectAttrFail comes when a resultset column cannot be converted:
dim Length as double
Length rs("TextStringColumn")

TIP 7 : Keywords: VB, Creating OLE servers

More information are accessible to get a more complete tlb. Look in Tools/Procedure Attribute
Interesting are

default property
 

TIP 8 : Keywords: VB, Interface is restricted

Compilation error coming sometimes without any line shown
Function or Interface marked as restricted ..
Recompile everything separatly. It can be an error in the order of recompilation mixed with CLSID changes. It can also be that one of the project used a binary compatibility reference use an interface which is not any  more referenced. A test could be to recompile without binary compatibility

TIP 22 : Keywords: VB, Interface is restricted

Compilation error coming sometimes with a slot shown that compiled correctly until just before
Function or Interface marked as restricted ..
Could be that one one the component is not compiled correctly. Message reference is corrupted or not compatible.

TIP 29 : Keywords: VB, Interface is restricted

If you have a server (dll) with binary compatibility with some copy of it or a reference tlb. You add new methods not existing in the reference you will not have warnings but the id of theses methods will be unstable. To fix this you have to remove binary compatibility and switch it on again

TIP 21 : Keywords: VB, VSS, Short Names

If you open a VB project from Windows Explorer the file name will be displayed  as a short name. This leads to problem in Visual Source Safe. Once you use VSS you must stay on the same method of open projects.

TIP 23 : Keywords: VB, comcat, components control

Don't show anything. Because comcat.dll must be 4.71. Could have been override by anothe software.

TIP 28 : Keywords: VB, Debug, local window

When looking at a variable object in the local window you get the following message:

Connection To Type Library for remote process has been lost. Press OK for dialog to remove reference.

TIP 29 : Keywords: VB, Typelibrary, idl

How to create the idl file of a VB program ?

  1. Run OLEView
  2. Open the vb executable or dll
  3. Cut paste the idl definition into a text file
  4. add all importlib (usually stdole2)
  5. move typedef at beginning
  6. replace boolean by variant_bool
  7. replace initial and final ( by {
  8. comment cancreate and predeclid
  9. ignore warning oleautomation due to ole_color and existing idispatch sub classes passed as parameters
  10. add forward decl for all definition of interfaces used before being declared.

 

TIP 46 : Keywords: VB, byval, byadr, exchanges with VC

In parameter, when there not byval in the interfaces then parameter is byadr. A byval parameter produce errors when exchanges between VC and VB ( cf ProjectM object)

TIP 48 : VB, Extending a Class with new methods

To Extend a class by adding new methods without breaking the binary compatibility

- Edit the class and add new methods at the end. If you want to add attributes do it using property get and put - Compile. No errors should come - Close the project - rename old ref file to something like ref1 - copy the dll to the ref - reload the project

Don't use any other project in between

The nice thing would be to increse some version information. I suggest increasing the minor version in this case.

Other projects referencing this project will update without complaining

There is another alternative is to add a new interface to an object and use the alternate interface to extend it. Note that if this interface is produced by another tool than VB like a simple idl compiler these problems of binary compatibility are not raised

TIP 50 : VB, OLE Automation, Exeption code

Any error or ole automation function call wich returns a HRESULT error code (FAILED(hr)) raises an "float conversion" exeption. Usual Errors :

typeof NOTHING
Setting an object in a typed variable wich does not fit.

TIP 54 : VB, Design Lisence

After some VB update or service pack you may experience problem when recompiling projects that worked fine before the update :  vb claims that you don't have the design lisence for a component.

On the VB5 CD, Under TOOLS, You'll find VBCTRLS.REG Doubleclick this one.
If this do not help, Goto www.microsoft.com/support and search for VBC.EXE
It could also have to do with Comcat.dll problem see: Q183370 and maybe Q177799
Another source of info are: http://www.mvps.org/vbnet/dev/devinfo/vbcpatch.htm External Link
Try to register mscomm32.ocx

 

Index

 

SolidWorks API

TIP 9 : Keywords: VB, SolidWorks, LineCreate

If the function fail it can be because the two ends are the same.Check that the snap to grid, or snap to angle is not set while running applications. Other cause of failure is to give a Z while in sketch mode.

TIP 10 : Keywords: VB, SolidWorks, Empty Typelibrary

Switch the hidden members option in the object browser

Index

 

VC

TIP 24 : Keywords: VC, Project files

.plg    Result form compilations, ...

.dsp    Project settings

.opt    Contents of ide.

TIP 25 : Keywords: VC, Smart Pointers, _com_ptr, #import

When using smart pointers together with #import of tlb there are some errors easy to do when you transform source code.

Error 1:
Source code before. GetCAMData is defined as a COM function.

IUnknown* pIUk;
pDataSource->GetCAMData( &pIUk);

if( pIUk )
{
    // Use pIUK;
    pIUk->Release();
}
                    

Source code step1. Due to use of #import, GetCAMData is defined as a c++ function returning a IMyInterfacePtr. The code is wrong because there is a Smart Pointer f type IMyInterfacePtr created without AddRef, return by the GetCAMData wrapper and drop once assigned to pIUk. If this was the last reference on the object it is lost. Of course the crash will be visible only later.

IUnknown* pIUk;
pIUk = pDataSource->GetCAMData();

if( pIUk )
{
    // Use pIUK;
    pIUk->Release();
}
                    

Source code step2. There are two options declare pIUk as a IUnknownPtr and remove the Release or use Detach

IUnknownPtr pIUk;
pIUk = pDataSource->GetCAMData();

if( pIUk )
{
    // Use pIUK;
}

Or

IUnknown* pIUk;
pIUk = pDataSource->GetCAMData().Detach();

if( pIUk )
{
    // Use pIUK;
    pIUk->Release();
}
                    

 

TIP 26 : Keywords: VC, Smart Pointers, _com_ptr

COM impose that all functions returning a COM pointer use AddRef on it before delivering it.

    IUnknownPtr m_Border;                    
/* [propget] */ 
HRESULT STDMETHODCALLTYPE CRSMyClass::get_Border( 
/* [retval][out] */ IUnknown __RPC_FAR *__RPC_FAR *R)
{
    if (m_Border)
	m_Border.AddRef();
    *R = m_Border;
    return S_OK;
}

For the put there is nothing to do.

/* [propput] */ 
HRESULT STDMETHODCALLTYPE CRSMyClass::put_Border( 
            /* [in] */ IUnknown __RPC_FAR *R)
{
    m_Border = R;
    return S_OK;
}
        
                    

TIP 27 : Keywords: VC, Smart Pointers, _com_ptr

Danger using & and Detach(). It resets the contents of the smart pointer.

 

TIP 40 : Keywords: VC, Last System error

The code fragment bellow can be used to view the last system error

{

    DWORD Errcode = GetLastError();
    LPVOID lpMsgBuf;
    FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER |
                              FORMAT_MESSAGE_FROM_SYSTEM |
                              FORMAT_MESSAGE_IGNORE_INSERTS, NULL,
                               Errcode,
                               MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
                               (LPTSTR) &lpMsgBuf,0, NULL );
    MessageBox( NULL, (LPTSTR)lpMsgBuf, _T("Error"),
                         MB_OK | MB_ICONINFORMATION );
    LocalFree( lpMsgBuf );
}

 

TIP 41 : Keywords: VC, Ascii, Unicode and MBCS

There is only one way to be quiet about Ascii, Unicode and MBCS especially in case of a code for both NT and Win95 : use TCHAR and only TCHAR

TCHAR* str = _T("My String")

Samples

for localization using multiple resource dll see the MFC sample Localize.

For dll auto registration see the sample register

see localization, auto registration and aut installation in the context of a SolidWorks addin see the radialsoft product  RSOLEDMKeyAddin

 

TIP 42 : Keywords: VC, separate resource only DLL

Here is a sample loading a resource only dll ( mfc )

BOOL CTestApp::InitInstance()
{ 
    if ((m_hInstDLL = LoadLibrary("resdll.dll"))== NULL)
    { 
        return FALSE; // Failed to load the localized resources.
    }
    else
    {
	// Get resources from the DLL.
        AfxSetResourceHandle(m_hInstDLL);
    }
}                      
int CTestApp::ExitInstance()
{
    FreeLibrary(m_hInstDLL);
    return CWinApp::ExitInstance();
}                      
the Dll iself just contain resource and a MainDLL function                    
defined as follow:                    
int CALLBACK LibMain(HINSTANCE, WORD, WORD, LPSTR)
{
    return 1;
}                    
This dll must be build using the /NOENTRY linker flag.                    

The resource itself is set using:

    HINSTANCE hResPrev = NULL;
    hResPrev = AfxGetResourceHandle();
    AfxSetResourceHandle(m_hInstDLL);
     // Here use the resouce
    AfxSetResourceHandle(hResPrev);                      

 

TIP 45 : Keywords: VC, OLEView

- OLEView.exe (VC5) crash in some conditions:

Too many interfaces in the registry
show a typelibrary containing vectors like HRESULT fct( double Vect[3]);

- OLEView.exe (VC5) show alos the PSOInterfaces implemented by the .oca files created by VB for each control used in a project.

- MIDL compiler (VC5): #importlib don't operate correctly if an interface is used a a parameter (IDMSurface in our case) as a parameter to a function of a new interface and if this interface (IDMSurface) is coming from a first GTForDMAC also used in a seconf library alos imported (DMCurve). Solution: reference explicitely the imported interface in the typelibrary (IDMSurface ). It is ducplicated but at least present.

TIP 49 : Keywords : Debug

A slot of an object or a variable change without explanation. May be another Threat check for existence of other threats May memory overlow. Put a temoin

Don't stay too long on debug No more than 2 persons on debug together.

MFC Either independent use of MFC use USRDLL (this is for controls for example) Either reuse same libs but independant use AFXDLL Either extension of another app with same object hiercahy AFXEXT

in 2 and 3 MFC must use the same version and some option of compilation. For example if you want debug all must be in debug.

TIP 51 : Keywords : Build an explorer like application or extension

see at Windows 95 Virtual Folders External Link

TIP 52 : Profiling a DLL.

Profiler can run on exe only so use an exe calling the dll

link the dll will "enable profiling" link the exe will "enable profiling"

in the exe project /build/profile use custom setting.

define a .bat file as follow

PREP /OM /FT c:\project\Toto.exe c:\project\Toto.dll COPY rskxf._ll c:\project\Toto.dll PROFILE c:\project\Toto.exe PREP /M LTPKxf PLIST Toto > Toto.out

The main point in this command file is the copy of the ._ll generated by PREP on the original DLL

TIP 53 : _bstr_t , conversion

Avoid the use of temporary _bstr_t for conversion

char* Local = (char*) _bstr_t(FileName);
..... using Local ........             

this is wrong because the temporary _bstr_t is deleted by the compiler on the first line, then the char* is also deleted, so the use of "Local" on the second line is a bug.

solution, here is the correct code

_bstr_t tmp(FileName);
char* Local = (char*) tmp;
..... using Local ........            

Index

 

ATL

TIP 11 : Keywords: tlb, idl

To get the tlb from the idl, use midl. An interface not connected to an object in a tlb will appear in VB as TypelibrayName.InterfaceName

TIP 12 : Keywords: idl, oleautomation,

If an argument is a COM object not inheriting from IDispatch then the warning not an oleautomation is output by midl. It means also thatthe interface will not be marshalled by standard marshalling. A custom arshalling will be necessary.

TIP 34 : Keywords: ATL, tlb, dual

If the code can't find the tlb inside the dll there is no complain but nothing works.

TIP 13 : Keywords: ATL,

To build MinDep choose MultithreadDLL and add

#ifdef ATL_STATIC_REGISTER
...
#endif

inside stdafx.cpp

the defines are

_USRDLL, _WINDLL, _MCBS, ATL_STAIC_REGISTER

TIP 20 : Keywords: ATL, Marshalling

To build the Marshalling dll for an interface. Create an ATL project and put you interface inline (no import) in the IDL of your project. It will build a Proxy Server project (Files with ps at end). Build it using the mak. Install it by self registration. Check with oleview section interface. You can also check with oleview by creating an instance with correct context and check your interface is available.

Index

 

FrontPage

TIP 14 : Keywords: FrontPage, Forum

Forum should always stay at the level of the web, not in subdirectory. Something is hard coded.

TIP 15 : Keywords: mail, mailto

To add the subject automatically mailto:xxx@cc.com?subject

TIP 16 : Keywords: table, form, html

Do not add Forms into table cells in frontapge otherwise an additionnal form feed is added

TIP 28 : Keywords: WebBot, error

You have to see inthe EventViewer the error message. You can also recalcultate server side webbots with fpsrvadm.exe

TIP 30 : Keywords: Preview, images

Images appear in preview but not in normal mode. Check if attributes like HEIGHt and WIDTh are in uppercase or lowercase. Should be in lower case for normal mode.

TIP 31 : Keywords: Recalculate

You can recalculte from a batch at given time if some pages are changed by other means than interactive frontpage: use fpsrvadm.exe in version3.0/bin. You can even recalculate one page only.

TIP 32 : Keywords: Open, corrupt

It is possible to open a web that can't be recalculate: set to 0 AutoRecalc in service.cnf in directory _vti_pvt. It will be reset to 1 after successfull opening.

TIP 33 : Keywords: WebBot, Server side

With the following conditions: nt server 4.0 sp3, fp98, iis3.0, proxy1, vc5.0 sp3 the webbot on serevr side don't operate in a stable way. Sometime it works sometimes not but it works rarely. In is not isnide the webbost but when the result is returned.

TIP 34 : Keywords: FrontPage, Proxy

Quite unstable, to avoid

TIP 36 : Keywords: FrontPage, Split Webs

A big web is difficult to maintain. To switch sub directories into sub webs

  1. Create an empty Web
  2. Copy parameters in service.cnf
  3. Copy top.htm (navlow.htm, navbar.htm)
  4. move from structure.cnf
  5. copy images_g to images
  6. in navbar1.htm update link to sub site which is now current
  7. Apply theme
  8. apply border

TIP 37 : Keywords: FrontPage, WebPost

WebPost say it send only modified but actually it sends all.

TIP 38 : Keywords: themes

Themes names should be in lower case to publish on unix

TIP 39 : Keywords: FrontPage, WebBot

To see a webbot on a site, you should copy the bot to the local directory and recalculate the hyperlinks of the site's root.

TIP 43 : Keywords: Frontpage, Form, AddInfo, Feedback Acknoledge

It seems that the page that is sent after a form has been submitted can not content any webbot. If not, the body of the page will not be displayed.

 

Index

 

Internet

TIP 17 : Keywords: ipconfig, tcp/ip, ip address, dialup

Always difficult to know its own ip address in case of dialup ip. Use ipconfig in a dos windows.
or winipcfg from ressource kit

TIP 18 : Keywords: temporary internet file,

Problem of temporary files on Windows NT. Message run scandisk.. This is because a connexion on internet was initiated by a service before any logged user did a connexion. Because there is only one the connexion is now initiated with a security of SYSTEM preventing the user to reuse it. To prevent this use internet explore immediatley after boot and first logging sequence. In case of problem reboot.

Tip 57 : Getting Knowledge Base Article

To receive a Knowledge Base Article mail mshelp@microsoft.com with the KB ref in subject (ie : Q155027)

Index

 

IIS

TIP 44 : Keywords: Stopping WWW Publishing Service

Use the Visual Studio debugger : in VS97 Menu Build/Start Debug/Attach to process... Check [Show System Process], select Inetinfo, pusk [OK]. Stop debugging

TIP 47 : Interaction with desktop, ActiveX Errors

In Control Panel\Services\IIS Admin\Startup and Control Panel\Services\W3 Publishing\Startup, if you set "can interact with desktop" you will see the full descriptions of Server-Side-callen ActiveX.

Index

 

Windows NT

TIP 55 : Windows NT, bootup keyboard layout

If you want to change your bootup keyboard layout to an azerty keyboard, modify your registry :

HKEY_USERS\.DEFAULT\Keyboard Layout\Preload

1 : REG_SZ = 0000040C

TIP 56 : Restoring registry saved with rdisk /s

expand c:\winnt\Repair\Software._ C:\WINNT\system32\config\Software
expand c:\winnt\Repair\Software._ C:\WINNT\system32\config\Software.sav
expand c:\winnt\Repair\Default._ C:\WINNT\system32\config\default
expand c:\winnt\Repair\Default._ C:\WINNT\system32\config\default.sav
expand c:\winnt\Repair\SAM._ C:\WINNT\system32\config\sam
expand c:\winnt\Repair\SAM._ C:\WINNT\system32\config\SAM.sav
expand c:\winnt\Repair\Security._ C:\WINNT\system32\config\security
expand c:\winnt\Repair\Security._ C:\WINNT\system32\config\security.sav
expand c:\winnt\Repair\System._ C:\WINNT\system32\config\system
expand c:\winnt\Repair\System._ C:\WINNT\system32\config\SYSTEM.ALT
expand c:\winnt\Repair\System._ c:\WINNT\system32\config\system.sav

Index

 

Office

Tips 58 : Displaying week number in outlook

Go to Tool/ option, Tab Calendar and check "show week number" Don't forget to set first week as First full week

Tips 58 : Change Templates directory

Change the value at : [HKEY_CURRENT_USER\ Software\ Microsoft\ Office \8.0\ Common\ FileNew\ LocalTemplates] to something like : @="\\\\Computer01\\Share01\\Folder01\\Templates\\"

Index Note this icon External Link indicates that the link wiil take you outside of this site.

           
Contact webmaster@radialsoft.com for comments about this website.
Copyright © 2000-2003 RadialSoft Corp - Last modified: December 1, 2003 - Disclaimer