月份:十一月 2006

How to add icons and images in NIB based Carbon application

Posted on Updated on

  1. build the icons as reouse file by IconBuilder. IconBuilder is plug-in of Adobe Photoshop or Macromedia Fireworks MX. Make sure the icon file made by IconBuilder is saved in .icns format. (for MAC of course)
  2. Drag the resource file into your Xcode project
  3. Open the nib file in your Xcode project, you can see the icons in Images tab

Reference:

廣告

How to make MAC OS X Package file (installation file)

Posted on Updated on

Use any the utilities:

  • PackageMaker: MAC default. in /Developer/Application/Utilities/
  • InstallVISE: support MAC OS 9/X Carbon applications.
  • InstallAnywhere: Java applications.

use php to parse the unicode passed by javascript’s escape()

Posted on

before using these code
set the html ‘s character set to utf8 first

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>


function ConvertToUTF8($ch){
  foreach($ch as $val){
  $val = intval(substr($val,2),16);
  if($val < 0x7F){ // 0000-007F
  $c .= chr($val);
  }elseif($val < 0x800) { // 0080-0800
  $c .= chr(0xC0 | ($val / 64));
  $c .= chr(0x80 | ($val % 64));
  }else{ // 0800-FFFF
  $c .= chr(0xE0 | (($val / 64) / 64));
  $c .= chr(0x80 | (($val / 64) % 64));
  $c .= chr(0x80 | ($val % 64));
  }
  }
  return $c;
}
function my_unicode_decode($str,$char_set)
{
  $conv_str = preg_replace_callback("/%u[0-9A-Za-z]{4}/",ConvertToUTF8,$str);
  return mb_convert_encoding($conv_str, $char_set, 'utf-8');
}

// t is passed from after javascript's escape() function
 echo urldecode( $_GET['t'] );
 echo urldecode ( "%u767D" ) ;
 echo htmlspecialchars(urldecode($_GET['t']));
 $str = my_unicode_decode($_GET['t'],'utf-8') ;
 echo $str ;

Carbon Get Text Control’s string

Posted on Updated on

Function:

void GetTextFromControl( WindowRef win, ControlID id, char *outStr, size_t len)
{
OSStatus err = noErr ;
ControlRef ctrl ;
CFStringRef str ;
Size actualsize ;
err = GetControlByID( win, &id, &ctrl) ;

GetControlData( ctrl,kControlEditTextPart , kControlEditTextCFStringTag, sizeof(CFStringRef ),&str,&actualsize) ;
//CFStringTrimWhitespace( (CFMutableStringRef) str) ;
CFStringGetCString(str, outStr,len, kCFStringEncodingASCII);
CFRelease( str);
}

Sample code:

ControlID ctrlID ;
ctrlID.signature = kEditLoginCodeSignature ;
ctrlID.id = kEditLoginCodeFieldID ;
char password[5] ;
GetTextFromControl( g_hMainWindow, ctrlID, password, sizeof(password) ) ;

Embed google map in your web site

Posted on Updated on

  1. Generate a key of google map, and get the html script from http://www.google.com/apis/maps/
  2. read the API documentation for details Google Map API documents

example site:
http://realtravel.com

my practice:
my practice

pthread priority setting

Posted on

Use pthread_attr_setschedparam() to set priority. the structure struct sched_param is used by this API. Set the priority for the thread to the member sched_priority in struct sched_param as you want. ** only priority sched_param.sched_priority is supported.

prototype:

int pthread_attr_setschedparam(pthread_attr_t *tattr, const struct sched_param *param);

example:

#include
pthread_t thread;
pthread_attr_t tattr;
sched_param param;
int ret ;
ret = sched_get_priority_max( PTHREAD_EXPLICIT_SCHED );
param.sched_priority = (ret

other related APIs:
int sched_get_priority_max(int policy);
int sched_get_priority_min(int policy);
int sched_get_priority ();
where policy could be PTHREAD_EXPLICIT_SCHED or PTHREAD_INHERIT_SCHED

Reference :

php upload

Posted on Updated on

紅色部分一定要加,不然會傳不上去。

enctype="multipart/form-data" action="__URL__" method="POST">


Send this file: