看到很多GUI繪圖軟體,都有提供「群組化」的功能
(也就是把很多個物件當作一個物件處理,當使用者點選群組中的某一個物件時,和他同一組的物件同時會被點選)
finalfrank 發表在 痞客邦 留言(3) 人氣(490)
系統流程 onPause() -> onStop() -> onDestroy()
以下是我試過最和平 不會產生錯誤訊息的方法
@Override
protected void onPause() //按下退出鍵 系統預設呼叫 onPause
{
finish();
super.onDestroy(); //這行以防系統以為我亂呼叫
}
@Override
protected void onStop()
{
super.onStop();
super.onDestroy();
finish();
}
@Override
protected void onDestroy(){ //真正作用區
super.onDestroy();
//Kill myself
android.os.Process.killProcess(android.os.Process.myPid());
}
finalfrank 發表在 痞客邦 留言(1) 人氣(5,699)
int 共有幾個元素;
int saveFile(){
move_phase=0;
picked=-1;
FILE *f1;
f1 = fopen ("save", "wb");
int i;
fprintf(f1,"%d ",共有幾個元素);
printf("[[%d ]]",共有幾個元素);
for(i=0;i<共有幾個元素;i++){
int j=0;
fwrite(poly,sizeof(struct POLYGONS),共有幾個元素,f1);
}
fclose (f1);
}
int readFile(){
move_phase=0;
picked=-1;
FILE *fPtr;
fPtr = fopen("save", "rb");
if (!fPtr) {
printf("檔案開啟失敗...\n");
return 0;
}
int status,i=0;
fscanf(fPtr,"%d ",&共有幾個元素);
status=fread(poly,sizeof(struct POLYGONS),共有幾個元素,fPtr);
printf("FETCHED %d POLYGONS@",status);
display();
fclose(fPtr);
return 0;
}
finalfrank 發表在 痞客邦 留言(0) 人氣(1,048)
新建專案 -> Console Application -> 選 DLL File
1. 在 DLL 檔裡面要先 Define 這行!
#define DLL extern "C" __declspec(dllexport)
2. 開始在 DLL 檔裡面寫 Function !!
DLL int sum(int c){ return ++c; }
--------------------------------------DLL 檔寫完了
如何呼叫 DLL 檔裡面的 Function ?
在一個MFC程式中..
HINSTANCE hinstDLL=LoadLibrary(L"theDLL.dll"); //讀取 DLL
if(hinstDLL!=0){ //如果有找到 DLL 檔
typedef int(__cdecl *Connect)(int i); //先宣告一下要連結的函式的prototype
Connect Proc; //宣告一下連結用的Connect指標 (應該是指標吧!?)
Proc = (Connect)GetProcAddress(hinstDLL,"sum"); //用Proc連結 DLL 中的函式
int get=Proc(2); //開始使用DLL中的函式,注意DLL中的函式名稱從sum變成Proc了
FreeLibrary(hinstDLL); //DLL用完沒有利用價值了,就可以扔了
CString g;
g.Format((CString)"%d",get); //這三行是顯示函式回傳的值,應該是2+1=3 才對
MessageBox(g);
}
else{ printf("找不到你的DLL檔啦!你放在哪裡!?"); }
finalfrank 發表在 痞客邦 留言(1) 人氣(1,171)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
char str[] = "This is a good example"; //要被分割的
char *s = strtok(str, " "); //分割的判斷字元
char *put[100]; //分割後放入新的字串陣列
int s_count=0; //分幾個了
while(s != NULL) {
put[s_count++]=s; //把分出來的丟進去 結果陣列
s = strtok(NULL, " "); //我不知道 這行幹嘛
}
for(int x=0;x<s_count;x++) //驗收成果
printf("%d %s\n",x,put[x]);
system("pause");
return 0;
}
/*補充 其實改成 strtok(str," @"); 這樣的話
即使是 This@is a good@example
也會分成 "This" "is" "a" "good" "example" 了*/
finalfrank 發表在 痞客邦 留言(2) 人氣(14,377)
與 C 的比較 :
比較對於程式人員,方便使用
finalfrank 發表在 痞客邦 留言(4) 人氣(36,699)
finalfrank 發表在 痞客邦 留言(0) 人氣(58,438)