Share my knowledge, feel my life. Eric Shan' Blog myBloggie 2.1.6 © 2005   
Sep 2008 October 2008 Nov 2008
S M T W T F S
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31  
Categories
About[5]
Blackberry[1]
dotNet and C Charp[1]
IPhone[10]
Life[4]
Unix&Linux[19]
WEB programming[16]
Windows API[5]
Windows Mobile[1]
Windows Multimedia[4]
Recent
CentOS mount CDrom and USB
CentOS GHOST(幽灵)漏洞修复方法
centos 改变语言并立即生效
centos vpn 接通后无法连接internet
让vlc播放中文字幕不出乱码
centos 取消屏保
php中ob_flush和flush的用法
CentOS检查,添加,删除自启动服务
CentOS中开机自动启动某个服务
Top命令中的翻页
Archives
February 2010[4]
September 2009[1]
August 2009[1]
January 2009[7]
October 2008[10]
June 2008[2]
December 2007[14]
November 2007[5]
May 2007[9]
April 2007[3]
March 2007[10]
User List
Eric Shan[66]
Search
Syndication
25 Oct 2008   08:20:14 am
MAC: create control or Window without NIB
Just see a way to create button by code. Very interested in create Mac application purely by code and without anything from IB.

http://www.cocoadev.com/index.pl?NSButton

For Window and how an application load an window without an NIB, see this one,

http://objectmix.com/c/177994-how-create-windows-without-nib.html


Code :

int main(int argc, char *argv[])
{
NSWindow *mainwin;
MainView *mainview;
NSRect scr_frame;
unsigned int style_mask;

NSAutoreleasePool *pool =[[NSAutoreleasePool alloc] init];

[NSApplication sharedApplication];

scr_frame=[[NSScreen mainScreen] visibleFrame];
style_mask=NSClosableWindowMask|NSMiniaturizableWi ndowMask|
NSResizableWindowMask|NSTitledWindowMask;
#ifdef GNUSTEP
scr_frame=[NSWindow frameRectForScreenRect:scr_frame styleMask:style_mask];
#endif
scr_frame=[NSWindow contentRectForFrameRect:scr_frame
styleMask:style_mask];

mainwin=[[NSWindow alloc]
initWithContentRect:scr_frame
styleMask:style_mask
backing:NSBackingStoreBuffered
defer:NO];
[mainwin makeKeyAndOrderFront:nil];
[mainwin setTitle:@"Visible screen window"];

mainview=[[MainView alloc] initWithFrame:scr_frame];
[mainwin setContentView:mainview];

[mainwin setReleasedWhenClosed:YES];

[pool release];
[NSApp run];
return 0;
}
Category : IPhone | Posted By : Eric Shan | Comments[0] | Trackbacks [0]
20 Oct 2008   09:42:21 am
Get print result from SQL statement
Some of my colleague is lazy, and create the report in SQL and refuse to create an interface for user to execute the SQL. The SQL looks like below. The 'print' make the result in the SQL server management message window. So I'm thinking to make an interface but I do not want to change the SQL, so that is mean I need to get the result from the 'print'. The google told me it is possible to create it through register an call back fuction is CS, but I want an C++ interface. So I finally find ODBC can do it.

Code :
Set @DueFromPBOC =(Select isnull(sum(isnull(ac.AccountBalance,0)),0) From View_Account_Log ac
Print 'Result = '+ Convert(varchar(50), @DueFromPBOC)


The process is just like below,

SQLAllocEnv
SQLAllocConnect
SQLConnect
SQLPrepare
SQLExecute

after that, using SQLGetDiagRec to find out the result from the SQL 'print'

Code :

i=1;
while ((rc2 = SQLGetDiagRec(SQL_HANDLE_STMT, hstmt, i, SqlState, &NativeError,
Msg, sizeof(Msg), &MsgLen)) != SQL_NO_DATA)
{
//DisplayError(SqlState,NativeError,Msg,MsgLen);
//printf("%s, %srn",SqlState, Msg);

printf("%srn",Msg);
i++;
// }
}


There are two points here,

1. The SQL sentence must have an zero (0x0) end, to let SQL server know the end of the sentense
2. Must use SQLExecute instead of SQLExecDirect, SQLExecDirect can not reture the entired message, and only reture first part if you have several select statement in one batch.
Category : Windows API | Posted By : Eric Shan | Comments[0] | Trackbacks [0]
 
1
Template theme : aura
Powered by myBloggie Copyright © 2004 2006
-- myWebland --

Sponsed by TNTSoft Store