Posts Tagged ‘programming’

Displaying graphics in Symbian exe programs.

星期日, 10月 19th, 2008

Displaying graphics in Symbian exe programs.

Generally, exe programs are used to implement servers (exedll, epocexe target type) or
simple console programs. This may lead to believe that graphical features are not available
for exe programs. This is not the case, and even though it might take some extra work to
set up an appropriate environment, this is quite straight forward to achieve, as the
following snippet will illustrate. This way, we can make use of graphics without having to
resort on a full blown application.
(more…)

Displaying controls in Symbian exe programs

星期日, 10月 19th, 2008

Displaying controls in Symbian exe programs

From Forum Nokia Wiki

If we now wanted to create and display a CCoeControl, we’d need to have a CONE environment (CCoeEnv) as a minimum, as this class is used internally by the control. This makes things easier, given that CCoeEnv, as its name implies, creates a whole environment for us, thus limiting our task to the proper control creation:

 (more...)

树形右击弹出

星期日, 8月 26th, 2007

void CMyView::OnRclick(NMHDR* pNMHDR, LRESULT* pResult) 
  {

  CListCtrl 
&CList = GetListCtrl();//获取当前列表控件的指针
  CMenu       menu ,* pSubMenu;//定义下面要用到的cmenu对象
  menu.LoadMenu(IDR_POPMENU);//装载自定义的右键菜单
  pSubMenu = menu.GetSubMenu(0);//获取第一个弹出菜单,所以第一个菜单必须有子菜单
  CPoint oPoint;//定义一个用于确定光标位置的位置
  GetCursorPos( &oPoint);//获取当前光标的位置,以便使得菜单可以跟随光标
  int istat=CList.GetSelectionMark();//用istat存放当前选定的是第几项
  CString pString =CList.GetItemText(istat,0);//获取当前项中的数据,0代表是第0列
  pString="您选择的路径是:"+pString ;//显示当前选择项
  MessageBox(pString);//显示当前选中的路径
  pSubMenu->TrackPopupMenu (TPM_LEFTALIGN, oPoint.x, oPoint.y, this); //在指定位置显示弹出菜单
  }

VC常用数据类型转换

星期日, 8月 26th, 2007

一、其它数据类型转换为字符串

  • 短整型(int) itoa(i,temp,10);///将i转换为字符串放入temp中,最后一个数字表示十进制 itoa(i,temp,2); ///按二进制方式转换
  • 长整型(long) ltoa(l,temp,10);
  • 浮点数(float,double) 用fcvt可以完成转换,这是MSDN中的例子: int decimal, sign; char *buffer; double source = 3.1415926535; buffer = _fcvt( source, 7, &decimal, &sign ); 运行结果:source: 3.1415926535 buffer: ‘31415927′ decimal: 1 sign: 0 decimal表示小数点的位置,sign表示符号:0为正数,1为负数
  • CString变量 str = "2008北京奥运"; buf = (LPSTR)(LPCTSTR)str;
  • BSTR变量 BSTR bstrValue = ::SysAllocString(L"程序员"); char * buf = _com_util::ConvertBSTRToString(bstrValue); SysFreeString(bstrValue); AfxMessageBox(buf); delete(buf);
  • CComBSTR变量 CComBSTR bstrVar("test"); char *buf = _com_util::ConvertBSTRToString(bstrVar.m_str); AfxMessageBox(buf); delete(buf);
  • _bstr_t变量 _bstr_t类型是对BSTR的封装,因为已经重载了=操作符,所以很容易使用 _bstr_t bstrVar("test"); const char *buf = bstrVar;///不要修改buf中的内容 AfxMessageBox(buf);
  • 通用方法(针对非COM数据类型) 用sprintf完成转换
  •  
    1. char  buffer[200];
    2. char  c = '1';
    3. int   i = 35;
    4. long  j = 1000;
    5. float f = 1.7320534f;
    6. sprintf( buffer, "%c",c);
    7. sprintf( buffer, "%d",i);
    8. sprintf( buffer, "%d",j);
    9. sprintf( buffer, "%f",f);

(more…)

[乱]mfc与sdk笔记[十四]

星期四, 8月 16th, 2007

关于链接库。大概的使用应该就这些吧。呵呵。
(more…)