?? dialog_slidercolor.c
字號:
p=p-> next -> before =left-> before ;
}//end if 2
else //括號前沒有函數名
{//else
left-> nCharDouble =0 ;//是一個數
left-> cChar =' ' ;
left-> dDouble = left-> next -> dDouble ;//用這個數取代 ( or [
left-> next =p-> next ;
p=p-> next -> before =left ;
}//end if
while(p!=phead)//向前找一個 ( or [
{ p=p-> before ;
if(p-> cChar == '(' || p-> cChar == '[')break ;
}
}//end if 1
}//end for
SiSlove(phead) ;//把最后沒有括號 的表達式再計算一下
}
void SiSlove(struct strData *left)
{
struct strData *first ;//left 固定,first 移動
int i ;
double add ;
for(first=left ;first-> cChar !=')' && first-> cChar !=']' && first-> next != NULL ;)//計算 * / ^ ! 剩下的累加
{
switch(first-> cChar)
{
case '^': //計算+2^3-,為+8-
first-> before -> dDouble =pow(first-> before -> dDouble ,first-> next -> dDouble ) ;
first-> before -> next = first-> next -> next ;
first-> next-> next -> before = first-> before ;
first = first-> next -> next ;
break ;
case '!'://計算-2!+, 為-2+
for( i=1, add=1 ;i<=(int)first-> before -> dDouble ;i++) add=add*i ;
first-> before -> dDouble =add ;
first-> before -> next =first-> next ;
first-> next -> before =first-> before ;
first=first-> next ;
break ;
case '*' : //計算 -2*5+ 為-10+
first-> before -> dDouble =first-> before -> dDouble * first-> next -> dDouble ;
first-> before -> next =first-> next -> next ;
first-> next -> next-> before =first-> before ;
first=first-> next -> next ;
break ;
case '/' : //計算 -10/2+ 為-5+
first-> before -> dDouble =first-> before -> dDouble / first-> next -> dDouble ;
first-> before -> next =first-> next -> next ;
first-> next -> next-> before =first-> before ;
first=first-> next -> next ;
break ;
default :
first=first-> next ;
break ;
}
}
first=left ;
if(first-> cChar == '-') //-w+32 為 q+32 q為-w 第一個是負號的處理
{
first-> nCharDouble =0 ;
first-> cChar =' ' ;
first-> dDouble =-1*first-> next -> dDouble ;
first-> next =first-> next -> next ;
first-> next -> next-> before =first ;
}
//計算加減
for(first=left ;first-> cChar !=')' && first-> cChar !=']' && first-> next != NULL ;first=first-> next )//+ -
{
if(first -> cChar == '-') left-> dDouble =left-> dDouble - first-> next -> dDouble ;
if(first -> cChar == '+') left-> dDouble =left-> dDouble + first-> next -> dDouble ;
}
}
double Fun_switch(double dkuo,char Funhuhao )
{
switch(Funhuhao)
{
case 'H' : return sin(dkuo) ;
case 'I' : return cos(dkuo) ;
case 'J' : mistake(Funhuhao,dkuo); return tan(dkuo) ;
case 'K' : mistake(Funhuhao,dkuo); return 1.0/tan(dkuo) ;
case 'L' : return sinh(dkuo) ;
case 'M' : return cosh(dkuo) ;
case 'N' : return tanh(dkuo) ;
case 'O' : mistake(Funhuhao,dkuo); return asin(dkuo) ;
case 'P' : mistake(Funhuhao,dkuo); return acos(dkuo) ;
case 'Q' : mistake(Funhuhao,dkuo); return log10(dkuo) ;
case 'R' : mistake(Funhuhao,dkuo); return log(dkuo) ;
case 'S' : mistake(Funhuhao,dkuo); return sqrt(dkuo) ;
}
return 'S';
}
void mistake(char cfun,double dkuo)
{
// cout<< "text error";
double dfun=dkuo;
switch(cfun)
{
case 'J' : if(fabs(dfun/pi-(long)(dfun/pi)-0.5)<=0.0000000001)
//::AfxMessageBox("error : tg的定義不對,x!=π/2±k*π,k∈Z,請檢查!!");
break;// dkou/pi是0.5 1.5 2.5
case 'K' : if(fabs(dfun/pi-(long)(dfun/pi))<=0.0000000001)
//::AfxMessageBox("error : ctg的定義不對,x!=k*π,k∈Z,請檢查!!");
break;// dkou/pi是0 1.0 2.0
case 'O' :if(fabs(dfun)>1)
//::AfxMessageBox("error : asin的定義大于1,不對,請檢查!!");
break;//
case 'P' :if(fabs(dfun)>1)
//::AfxMessageBox("error : acos的定義大于1,不對-1<x<1,請檢查!!");
break;//
case 'Q' :if(dfun<0)
//::AfxMessageBox("error : lg的定義小于0,不對 x>0,請檢查!!");
break;//
case 'R' :if(dfun<0)
//::AfxMessageBox("error : log的定義小于0,不對 x>0,請檢查!!");
break;//
case 'S' :if(dfun<0)
//::AfxMessageBox("error : sqrt的定義小于0,不對 x>0,請檢查!!");
break;//
}
}
//////////////////////////////////////////////////////////////////////
void MyProcess(int Key)
{
char cBuf[1024];
int index=Key-idBtn;
int nlen;
if(index<0 || index>=40)
return;
#ifdef MYMUL
switch(index)
{
case 23:
MULTIEDIT_GetText(hEdit,cBuf,1024);
nlen=strlen(cBuf);
if (nlen) {
cBuf[nlen-1]=0;
MULTIEDIT_SetText(hEdit,cBuf);
}
break;
case 20:
cBuf[0]=0;
MULTIEDIT_SetText(hEdit,cBuf);
break;
case 38:
{
char char_result[1024];
MULTIEDIT_GetText(hEdit,cBuf,1024);
strcat(cBuf,"=");
Start_StrToUnionClass( cBuf) ;
translate_char();
Start_CountClass(head);
OnSLOVE() ;
//_gcvt( head->dDouble,10, char_result);
//sprintf(char_result,"%.3f",head->dDouble);
doubletochar(char_result,head->dDouble);
strcat(cBuf,char_result);
MULTIEDIT_SetText(hEdit,cBuf);
Kill_StrToUnionClass();
}
break;
default:
MULTIEDIT_GetText(hEdit,cBuf,1024);
strcat(cBuf,strBtn[index]);
MULTIEDIT_SetText(hEdit,cBuf);
}
#else
switch(index)
{
case 23:
EDIT_GetText(hEdit,cBuf,1024);
nlen=strlen(cBuf);
if (nlen) {
cBuf[nlen-1]=0;
EDIT_SetText(hEdit,cBuf);
}
break;
case 20:
cBuf[0]=0;
EDIT_SetText(hEdit,cBuf);
break;
case 38:
{
char char_result[1024];
EDIT_GetText(hEdit,cBuf,1024);
strcat(cBuf,"=");
Start_StrToUnionClass( cBuf) ;
translate_char();
Start_CountClass(head);
OnSLOVE() ;
//_gcvt( head->dDouble,10, char_result);
//sprintf(char_result,"%.3f",head->dDouble);
doubletochar(char_result,head->dDouble);
strcat(cBuf,char_result);
EDIT_SetText(hEdit,cBuf);
Kill_StrToUnionClass();
}
break;
default:
EDIT_GetText(hEdit,cBuf,1024);
strcat(cBuf,strBtn[index]);
EDIT_SetText(hEdit,cBuf);
}
#endif
}
/*********************************************************************
*
* Dialog resource
*
* This table conatins the info required to create the dialog.
* It has been created manually, but could also be created by a GUI-builder.
*/
/*
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
{ FRAMEWIN_CreateIndirect, "Dialog", 0, 30, 5, 260, 230, FRAMEWIN_CF_MOVEABLE, 0 },
{ BUTTON_CreateIndirect, "OK", GUI_ID_OK, 100, 5, 60, 20 },
{ BUTTON_CreateIndirect, "Cancel", GUI_ID_CANCEL, 100, 30, 60, 20 },
{ TEXT_CreateIndirect, "LText", 0, 10, 55, 48, 15, TEXT_CF_LEFT },
{ TEXT_CreateIndirect, "RText", 0, 10, 80, 48, 15, TEXT_CF_RIGHT },
{ EDIT_CreateIndirect, NULL, GUI_ID_EDIT0, 60, 55, 100, 15, 0, 50 },
{ EDIT_CreateIndirect, NULL, GUI_ID_EDIT1, 60, 80, 100, 15, 0, 50 },
{ TEXT_CreateIndirect, "Hex", 0, 10, 100, 48, 15, TEXT_CF_RIGHT },
{ EDIT_CreateIndirect, NULL, GUI_ID_EDIT2, 60, 100, 100, 15, 0, 6 },
{ TEXT_CreateIndirect, "Bin", 0, 10, 120, 48, 15, TEXT_CF_RIGHT },
{ EDIT_CreateIndirect, NULL, GUI_ID_EDIT3, 60, 120, 100, 15 },
{ LISTBOX_CreateIndirect, NULL, GUI_ID_LISTBOX0, 10, 10, 60, 40 },
{ CHECKBOX_CreateIndirect, NULL, GUI_ID_CHECK0, 10, 140, 0, 0 },
{ CHECKBOX_CreateIndirect, NULL, GUI_ID_CHECK1, 30, 140, 0, 0 },
{ SLIDER_CreateIndirect, NULL, GUI_ID_SLIDER0, 60, 140, 180, 20 },
{ SLIDER_CreateIndirect, NULL, GUI_ID_SLIDER1, 10, 170, 230, 30 },
{ DROPDOWN_CreateIndirect, NULL, GUI_ID_DROPDOWN0, 170, 10, 80, 60, 0, 3 },
{ DROPDOWN_CreateIndirect, NULL, GUI_ID_DROPDOWN1, 170, 60, 80, 60, 0, 3 }
};
*/
static const GUI_WIDGET_CREATE_INFO _aDialogCreate[] = {
{ FRAMEWIN_CreateIndirect, "Dialog", 0, 5, 5, 260, 260, FRAMEWIN_CF_MOVEABLE, 0 },
//{ BUTTON_CreateIndirect, "OK", GUI_ID_OK, 100, 5, 60, 20 },
//{ BUTTON_CreateIndirect, "Cancel", GUI_ID_CANCEL, 100, 30, 60, 20 },
//
{ BUTTON_CreateIndirect, "OK", idBtn, 100, 5, 30, 30 },
{ BUTTON_CreateIndirect, "OK", idBtn+1, 100, 5, 30, 30 },
{ BUTTON_CreateIndirect, "OK", idBtn+2, 100, 5, 30, 30 },
{ BUTTON_CreateIndirect, "OK", idBtn+3, 100, 5, 30, 30 },
{ BUTTON_CreateIndirect, "OK", idBtn+4, 100, 5, 30, 30 },
{ BUTTON_CreateIndirect, "OK", idBtn+5, 100, 5, 30, 30 },
{ BUTTON_CreateIndirect, "OK", idBtn+6, 100, 5, 30, 30 },
{ BUTTON_CreateIndirect, "OK", idBtn+7, 100, 5, 30, 30 },
{ BUTTON_CreateIndirect, "OK", idBtn+8, 100, 5, 30, 30 },
{ BUTTON_CreateIndirect, "OK", idBtn+9, 100, 5, 30, 30 },
{ BUTTON_CreateIndirect, "OK", idBtn+10, 100, 5, 30, 30 },
//
{ BUTTON_CreateIndirect, "OK", idBtn+11, 100, 5, 30, 30 },
{ BUTTON_CreateIndirect, "OK", idBtn+12, 100, 5, 30, 30 },
{ BUTTON_CreateIndirect, "OK", idBtn+13, 100, 5, 30, 30 },
{ BUTTON_CreateIndirect, "OK", idBtn+14, 100, 5, 30, 30 },
{ BUTTON_CreateIndirect, "OK", idBtn+15, 100, 5, 30, 30 },
{ BUTTON_CreateIndirect, "OK", idBtn+16, 100, 5, 30, 30 },
{ BUTTON_CreateIndirect, "OK", idBtn+17, 100, 5, 30, 30 },
{ BUTTON_CreateIndirect, "OK", idBtn+18, 100, 5, 30, 30 },
{ BUTTON_CreateIndirect, "OK", idBtn+19, 100, 5, 30, 30 },
{ BUTTON_CreateIndirect, "OK", idBtn+20, 100, 5, 30, 30 },
// 25, 25 }, 30, 30 },
{ BUTTON_CreateIndirect, "OK", idBtn+21, 100, 5, 30, 30 },
{ BUTTON_CreateIndirect, "OK", idBtn+22, 100, 5, 30, 30 },
{ BUTTON_CreateIndirect, "OK", idBtn+23, 100, 5, 30, 30 },
{ BUTTON_CreateIndirect, "OK", idBtn+24, 100, 5, 30, 30 },
{ BUTTON_CreateIndirect, "OK", idBtn+25, 100, 5, 30, 30 },
{ BUTTON_CreateIndirect, "OK", idBtn+26, 100, 5, 30, 30 },
{ BUTTON_CreateIndirect, "OK", idBtn+27, 100, 5, 30, 30 },
{ BUTTON_CreateIndirect, "OK", idBtn+28, 100, 5, 30, 30 },
{ BUTTON_CreateIndirect, "OK", idBtn+29, 100, 5, 30, 30 },
{ BUTTON_CreateIndirect, "OK", idBtn+30, 100, 5, 30, 30 },
// 25, 25 }, 30, 30 },
{ BUTTON_CreateIndirect, "OK", idBtn+31, 100, 5, 30, 30 },
{ BUTTON_CreateIndirect, "OK", idBtn+32, 100, 5, 30, 30 },
{ BUTTON_CreateIndirect, "OK", idBtn+33, 100, 5, 30, 30 },
{ BUTTON_CreateIndirect, "OK", idBtn+34, 100, 5, 30, 30 },
{ BUTTON_CreateIndirect, "OK", idBtn+35, 100, 5, 30, 30 },
{ BUTTON_CreateIndirect, "OK", idBtn+36, 100, 5, 30, 30 },
{ BUTTON_CreateIndirect, "OK", idBtn+37, 100, 5, 30, 30 },
{ BUTTON_CreateIndirect, "OK", idBtn+38, 100, 5, 30, 30 },
{ BUTTON_CreateIndirect, "OK", idBtn+39, 100, 5, 30, 30 }
/*25, 25 },30, 30 },
{ TEXT_CreateIndirect, "LText", 0, 10, 55, 30, 30 }, 25, 25 }, 48, 15, TEXT_CF_LEFT },
{ TEXT_CreateIndirect, "RText", 0, 10, 80, 48, 15, TEXT_CF_RIGHT },
{ EDIT_CreateIndirect, NULL, GUI_ID_EDIT0, 60, 55, 100, 15, 0, 50 },
{ EDIT_CreateIndirect, NULL, GUI_ID_EDIT1, 60, 80, 100, 15, 0, 50 },
{ TEXT_CreateIndirect, "Hex", 0, 10, 100, 48, 15, TEXT_CF_RIGHT },
{ EDIT_CreateIndirect, NULL, GUI_ID_EDIT2, 60, 100, 100, 15, 0, 6 },
{ TEXT_CreateIndirect, "Bin", 0, 10, 120, 48, 15, TEXT_CF_RIGHT },
{ EDIT_CreateIndirect, NULL, GUI_ID_EDIT3, 60, 120, 100, 15 },
{ LISTBOX_CreateIndirect, NULL, GUI_ID_LISTBOX0, 10, 10, 60, 40 },
{ CHECKBOX_CreateIndirect, NULL, GUI_ID_CHECK0, 10, 140, 0, 0 },
{ CHECKBOX_CreateIndirect, NULL, GUI_ID_CHECK1, 30, 140, 0, 0 },
{ SLIDER_CreateIndirect, NULL, GUI_ID_SLIDER0, 60, 140, 180, 20 },
{ SLIDER_CreateIndirect, NULL, GUI_ID_SLIDER1, 10, 170, 230, 30 },
{ DROPDOWN_CreateIndirect, NULL, GUI_ID_DROPDOWN0, 170, 10, 80, 60, 0, 3 },
{ DROPDOWN_CreateIndirect, NULL, GUI_ID_DROPDOWN1, 170, 60, 80, 60, 0, 3 }
*/
};
/*********************************************************************
*
* Initializers for listbox
*/
static const GUI_ConstString _apListBox[] = {
"English", "Deutsch", "Fran鏰is", "Japanese", "Italiano", NULL
};
/*******************************************************************
*
* static code
*
********************************************************************
*/
/*********************************************************************
*
* _cbBkWindow
*/
static void _cbBkWindow(WM_MESSAGE* pMsg) {
switch (pMsg->MsgId) {
case WM_PAINT:
GUI_SetBkColor(GUI_RED);
GUI_Clear();
GUI_SetColor(GUI_WHITE);
GUI_SetFont(&GUI_Font24_ASCII);
GUI_DispStringHCenterAt("DIALOG_All - Sample", 160, 5);
break;
default:
WM_DefaultProc(pMsg);
}
}
/*********************************************************************
*
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -