月份:十二月 2006

如何在 IE 的右鍵選單中加入項目

Posted on Updated on

  1. 編輯 registry 在 HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt 裡面加入一個機碼,例如:Cotton Search
  2. 在這個機碼的預設值當中填入你要執行點選右鍵之後的執行檔名稱或是html(裡面可以放 java script)等等,必須與下一個值Context的資料配合。
  3. 加入一個值名稱為Context類型可以是Binary 或是 DWORD 他的資料可以是下列的一項組合,表示你目前選取的物件文字…是下列組合的時候,右鍵選單中可以看到你設定的機碼(Cotton Search)
    Context Value
    Default 0x01
    Images 0x02
    Controls 0x04
    Tables 0x08
    Text selection 0x10
    Anchor 0x20

Reference:

Can’t find Atlapp.h

Posted on

Install WTL to solve this problem.
WTL download

Carbon PostEventToQueue sample code prevent from crash of windows and controls

Posted on Updated on

this sample function just presents the example to send command event into queue, this could prevent from thread unsafe problem that cause control or window crashed when you send event from a process to another,

  • remember that control and window events should be processed in main thread.
  • PostHICommand seems like call event handle directly, so use PostEventtoQueue is a better solution

mySendEvent(UInt32 commandID)
{
EventRef nextEvent = NULL;
HICommandExtended nextCmd;

CreateEvent(NULL,kEventClassCommand,kEventCommandProcess,kEventDurationMicrosecond,kEventAttributeUserEvent,&nextEvent);
memset(&nextCmd,0,sizeof(HICommandExtended)) ;
nextCmd.commandID = commandID ;
//nextCmd.menu.menuRef =0 ;
//nextCmd.menu.menuItemIndex = 0 ;
SetEventParameter(nextEvent,kEventParamDirectObject,typeHICommand,sizeof(nextCmd),&nextCmd) ;
PostEventToQueue(GetMainEventQueue(),nextEvent,1) ;
ReleaseEvent(nextEvent) ;
}

Localize the multi-language strings

Posted on

  1. in your source code, use the codes CFCopyLocalizedStringxxxxxx to get the strings you want

    mystr = CFCopyLocalizedStringFromTable(CFSTR("Searching ...") , CFSTR("Localized"),NULL);
    the ‘Localized‘ is the table name, in fact it’s the string file name Localized.string without the extension ‘.string‘, and ‘Searching…‘ is the key of the string you want to get, you could set the 2 values as you want, the tools genstrings will refer to the 2 values to generate the string table file “Localized.string" automatically.

  2. use the string table generation tool genstrings to generate the string table, in you shell,

    % genstrings <sourcefile_name>

    there will be string files in the target directory,

    • if you add -d <target_dir>, after genstrings, the string files will be stored in target_dir
    • if there are many line of CFCopyLocalizedStringxxxxx function with different table name parameter, genstrings will generate lots of string files
  3. add the string files into your Xcode project
  4. open information of the string file, press the “make localizable" button, and add localization files
  5. open each language of your string files and modify the values after the “=" mark, the content format of the file is “key" = “value"
  6. to test the result, change your language in the “System Performance"/"International" and run your application
  7. the default languages supported by Xcode of localization are few, if your language is not listed by Xcode localization, please refer to ISO’s definition, for example, “zh_TW" refers to Traditional Chinese, “zh_CN" refers to Simiplified Chinese

Carbon resource files Localization

Posted on

Create a lproj file with zh_TW ISO code.
Reference :

About box of developed application

Posted on Updated on

for each appication, there’s a menu item named “About xxxx" on the menu.
this script state how the setup the about box(dialog) by using Xcode

  1. open the Info.plist file created by Xcode, it’s a xml format file, there are lots of tags “<key>" in the file.
  2. the key CFBundleGetInfoString is the statement that’s shown at the buttom of the “About box"
  3. the key CFBundleIconFile is the icon that’s shown on the About box
  4. the key CFBoundleVersion is the version shown on the About box
  5. you has to add an .icon file into your project, and then open the dialog by select the item in Xcode’s menu Project/Edit Active Target <your target >, select the Properties tag, then drag the icon file to the into rectangle in the dialog after “Icon File"


ipaddress and mac address and net interface enumerator

Posted on Updated on

Down load the file, rename it as AddressLister.zip then decompress it by
% unzip AddressLister.zip

download

sample code:

#include “AddressLister.h"

main ()
{
CAddressLister oAddr;
int count ;
char ip[CAddressLister::IPLEN];
char mac[CAddressLister::MACLEN];
char ifs[50];
unsigned long ulip ;

oAddr.run();
count = oAddr.count();
for ( int i = 0 ;i < count ; i ++)
{
oAddr.getInterface(i,ifs) ;
oAddr.getIPAddress(i,ip);
oAddr.getIPAddress(i,ulip);
oAddr.getMACAddress(i,mac);
printf(“%s %s %-15s 0x%08X\n",ifs,mac,ip,ulip) ;
}
}