月份:一月 2007

How to fix “C1001: INTERNAL COMPILER ERROR" for VC 5.0/6.0?

Posted on

Refer to Here.

廣告

How to add image in Carbon bundle?

Posted on Updated on

Steps

  1. Add the jpg files to your project. Here, you have add images in Carbon bundle.
  2. to load jpg file from boundle:
  3. CGImageRef hImage = GetBoundleImage( “YOUR_IMAGE_FILE_NAME" ) ;

    CGImageRef GetBoundleImage( char * inUrl)
    {
    CGDataProviderRef provider;
    CFBundleRef appBundle = ::CFBundleGetMainBundle();
    CGImageRef image = NULL;
    CFStringRef urltmp ;
    url2 = CFStringCreateWithCString(NULL,inUrl,kCFStringEncodingASCII) ;
    if ( appBundle )
    {
    CFURLRef url = CFBundleCopyResourceURL( appBundle, urltmp, NULL, NULL );
    if ( url != NULL)
    provider = CGDataProviderCreateWithURL( url );
    else
    {
    printf(“GetBoundleImage: can’t get resource url %s\n",inUrl);
    return NULL;
    }
    image = CGImageCreateWithJPGDataProvider( provider,
    NULL, false, kCGRenderingIntentDefault) ;
    CGDataProviderRelease( provider );
    CFRelease( url );
    }
    CFRelease( urltmp );
    return image;
    }

  4. set the image to a HIView Control
  5. HIViewRef hHIView;
    HIViewRef hContentView;
    /* ‘sign’ and 1234 are what you set for the HIImageView control in IB */
    const HIViewID kHIViewID = { ‘sign’, 1234 };
    /* to get the handler of the HIImageView control, hWindow is
    the window handler which the HIImageView is placed in */
    GetRootControl( hWindow,&hContentView);
    HIViewFindByID( hContentView, kHIViewID, &hHIView);
    HIImageViewSetImage( hHIView, hImage ) ;
    CGImageRelease(hImage);

References:

Carbon: get Keyboard event

Posted on Updated on

  1. create event with a window where the keyboard event to be catched.
  2. const EventTypeSpec kLoginWindowEvents[] =
    {
    {kEventClassKeyboard, kEventRawKeyDown}
    } ;

    InstallWindowEventHandler( myWindow, GetWindowEventHandlerUPP(),
    GetEventTypeCount( kLoginWindowEvents ), kLoginWindowEvents,
    myWindow, NULL );

    myWindow is the window reference(WindowRef) that you create from NIB or…

  3. create an event handler
  4. DEFINE_ONE_SHOT_HANDLER_GETTER( WindowEventHandler ) ; // this macro defined in CarbonEvent.h
    OSStatus WindowEventHandler( EventHandlerCallRef inCaller, EventRef inEvent, void* inRefcon )
    {
    OSStatus err = eventNotHandledErr;
    UInt32 keyPressed ;
    UInt32 kMyCommandID = ‘comd’ ;
    switch ( GetEventClass( inEvent ) )
    {
    case kEventClassKeyboard:
    {
    switch ( GetEventKind(inEvent) )
    {
    case kEventRawKeyDown :
    GetEventParameter(inEvent,kEventParamKeyCode,typeUInt32,NULL,
    sizeof(UInt32),NULL,&keyPressed) ;
    if ( keyPressed == 36 || keyPressed == 76) // 36: return; 76: enter
    mySendCommand( kMyCommandID ) ;

    break;

    case kEventRawKeyRepeat:
    case kEventRawKeyUp:
    case kEventRawKeyModifiersChanged:
    case kEventHotKeyPressed:
    case kEventHotKeyReleased:
    break;
    }
    }
    break;
    }
    }

How to get the url of an anchor or an image by drag and drop?

Posted on

drag the anchor, or the image, in a browser to another one, call reciever, the reciever can get the url of the anchor by:
1. in the reciever set the handler of the event “ondrop"


<div ondrop="GetURL();">
</div>

2. in the event handler get the data “URL" from the object, dataTransfer, of event


<script type="text/javascript">
function GetURL()
{
alert (event.dataTransfer.getData("URL") );
}
</scrip>

Reference:

software packing with NullSoft Install Shield and MicroSoft certification

Posted on Updated on

Steps

  1. install MSVS or Authenticode SDK
  2. write down the scripts in a batch file( cert.bat for example)
  3. set TimeURL=http://timestamp.verisign.com/scripts/timstamp.dll
    echo making certification …
    “C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\makecert.exe" -n CN=test.com -sv test.pvk test.cer
    echo converting certification files …
    “C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\cert2spc.exe" test.cer test.spc
    “C:\Program Files\Microsoft Visual Studio 8\Common7\Tools\Bin\pvk2pfx.exe" -pvk test.pvk -spc test.spc -pfx test.pfx -f
    echo signing test.cab …
    “C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\signtool.exe" sign /f test.pfx /t %TimeURL% /v test.cab

    p.s.: This could only generate a test digital signature
    if you want to generate an enterprise CA of your company by IIS. please refers to the 3rd item of the following eferences :

Reference:

  1. Microsoft Authenticode Technology
  2. Packaging ActiveX
  3. Sign Code
  4. 在Web Server上設置安全的SSL

How to get Anchor from an Element of a document

Posted on

Sub myFunction(Url,Info)
On Error Resume Next
set myObj=CreateObject(“myATL.UrlSetter.1″)
if err0 then
MsgBox(“myObj not properly installed"+ vbCrLf+"Please install myObj again")
else
myObj.SetURL2(Url)
end if
end sub

Sub OnContextMenu()

set srcEvent = external.menuArguments.event
set EventElement = external.menuArguments.document.elementFromPoint ( srcEvent.clientX, srcEvent.clientY )
if srcEvent.type = “MenuExtAnchor" then

set srcAnchor = EventElement
do until TypeName(srcAnchor)="HTMLAnchorElement"
set srcAnchor=srcAnchor.parentElement
Loop
Call myFunction(srcAnchor.href,srcAnchor.innerText)
elseif srcEvent.type="MenuExtImage" then

if TypeName(EventElement)="HTMLAreaElement" then
Call myFunction(EventElement.href,EventElement.Alt)
else
set srcImage = EventElement
set srcAnchor = srcImage.parentElement
do until TypeName(srcAnchor)="HTMLAnchorElement"
set srcAnchor=srcAnchor.parentElement
if TypeName(srcAnchor)="Nothing" then
call myFunction(srcImage.href,srcImage.Alt)
exit sub
end if
Loop
Call myFunction(srcAnchor.href,srcImage.Alt)
end if
elseif srcEvent.type="MenuExtUnknown" then

set srcAnchor = EventElement
do until TypeName(srcAnchor)="HTMLAnchorElement"
set srcAnchor=srcAnchor.parentElement
if TypeName(srcAnchor)="Nothing" then
Call myFunction(EventElement.href,EventElement.innerText)
exit sub
end if
Loop
Call myFunction(srcAnchor.href,srcAnchor.innerText)
elseif 1=1 then
MsgBox(“Unknown Event Source “"" + srcEvent.type + “""" + vbCrLf + “")
end if
end sub

call OnContextMenu()

ATL Release Mode compile error: error LNK2001: unresolved external symbol _main

Posted on Updated on

Problem:
Build ATL project in debug mode, it’s okey. But in Release Mode, it shows the following message:

Compiling resources…
Linking...
Creating library ReleaseMinSize/BTBoxATL.lib and object ReleaseMinSize/BTBoxATL.exp
LIBCMT.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
ReleaseMinSize/ABCATL.dll : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

ABCATL.dll - 2 error(s), 0 warning(s)

Solution:

  1. remove the symbol _ATL_MIN_CRT from the release configurations
  2. or

  3. remove all dependencies on the C run-time library

Why ??
In ATL programming guild, developers shouldn’t use CRT functions. So, the atl wizard add the symbol _ATL_MIN_CRT to release mode configurations for the main reason, to reduce the size of executable, about 25K saved. _ATL_MIN_CRT symbol also solves the dependency on MSVCRT.dll problem without having to statically link CRT into executable.