29 9月 2010

[C# Study Note.1] Methods mapping from MFC to WinForm

Due to the past working requirement, I was used to coding on C++/MFC.
Fortunately, here comes a new project. And the source project from manufacturer is created on C#/Windows From.
So, I can study new language at the office time. :P

1. Note some methods which have the same function but without same name down. it's hard to find out when I studied the new language.

MFC/C++ WinForm/C#
1   OnEraseBkgnd() OnPaintBackground()
2   OnClose() OnFormClosed(), OnFormClosing()
3 OnCreate() Controls:OnCreateControl(), Forms:OnLoad()


28 9月 2010

[Implement] How C# use native library from C code

Target platform: Visual C# 2010 Express
Source platform: Visual C++ 2005 Professional ( to generate the DLL file )


[Part A] : To create a native C library (.dll)
1. new project --> Win32 project ( Note: not MFC --> MFC DLL ) --> in the application setting page,
select the below properties: (type:DLL), (additional options:Export symbols)

2. in your header file of the project, define the export function like this:

( DLLRESPIRATION0927 is my project name.)


// my export method 
extern "C" DLLRESPIRATION0927_API int  __stdcall fnRespiration( int count,short buffer[] );
Note:
if you don't add the macro extern "C", Visual C# will appear the error message: "Unable to find  an entry point", when you call this method.
if you don't add the macro __stdcall, the C# program can't find this function.

About extern "C",
because the C++ has the overloading function, it won't be supported by C.
We use this macro to close the overloading mechanism in C++ compiler.

3. in the .cpp file, declare the function like this:

DLLRESPIRATION0927_API int __stdcall fnRespiration(int count,short buffer[])
{
    return 0;
}


15 9月 2010

First C# Work.  

I'm so touched by this work. 
It was meaningful for me, because I finally walked out from C++/MFC area to create a UI work. ( Although my Java serial reader is pending, it'll be done. I KNOW :D ) 


Due to the current project will be developed on VS2008 with C#, 
it push me to self- study that.
And then I think I should leave a solid work to prove my ability. 
This is a good habit for other programming languages in the future, I trust. 


Work: C# Serial Watcher. It's a real-time display UI to draw the continuous input raw-data from serial port.
Equipment: SpO2 module. 
( the device developed by our department, and it's easy to demo the real-time drawing job. And it's idle, nearby my desk... ) 


Did you mention that countdown days in the up-right corner? yes, I must stay here for my military service. Won't refer to the device too much.. :)


This application is created by Visual C# 2010. It includes one drawing class, and a worker thread to handle the monitoring job for serial port.


It's a simple project, especially when compared to other great works in the CodeProject. If there's any thing that this work can help you. I'll very happy to share.


murmur too much, and depth is too swallow. keep studying~ :P
      

10 9月 2010

Micro - Blog

整天的電腦螢幕 整夜欲罷不能的電影 原已放棄開電腦紀錄下 這個夜晚的精采
洗完澡 思考著 有沒有可能五行文字 紀錄 不花費太多時間...


兩集的電影 『一球成名三部曲』 三與一  沉醉在此類夢想成真的澎湃中無法靜止
向來無法抗拒這類劇情 也許是白日夢做多了 又或者心中仍無法放下對未來的憧憬 
那麼一點不甘於平凡吧... 


今天竟將第一集 再看了1.5次 除想起在研究所 第一次看時的人事物 
過於過去的不成熟 有點感傷...


不舒服的情緒放一邊 轉個念頭想著 如果當初有著習慣紀錄下當時的心情、感動  
在這時間點再回頭去看 不知道是什麼樣的感覺
於是為了 下一次的感動 先記住當下;


滿滿的感動 帶有一點點空虛 空虛的是 向來的感動 都是跟自己說
或許有人願意聽 或許自己太多堅持 


還是不成熟地 活在只有自己的世界裡。 

03 9月 2010

可以自己掌握的事

一整日不間斷的C# + Windows Form 終究在回家 與沙發一起看完一集CSI後
不支倒地 (床墊在地板上 :P )


06:22 是起床的時間


美好的清晨 窗外有著麻雀充滿活力的叫聲 空氣中還有股專屬於早起的味道 
坐在沙發上 望著落地窗外的大樹、藍天、白雲 突然有種開心..


因工作 我們大多無法掌握能否天天享受到無限好的夕陽
但.. 
如果能妥善安排生活作息 我可以一周享受七次這樣的美好時光 這樣的生活
真好 真好


很想用照片告訴你 我和我的眼睛現在一起享受的畫面 只可惜客廳有點亂 下次唄。