2011年3月29日 星期二

Installshield Change Dialog Bitmap

To change Dialog Banner or Bitmap of Installshield dialog may reference this article
:http://www.flexerasoftware.com/webdocuments/PDF/DialogBitmaps.pdf

However, a simple way I used is just to override the default banner or bitmap  ibd file

(1) find the default ibd path

[INSTALLSHIELD_PATH]\Redist\Language Independent\OS Independent

ex: C:\Program Files\InstallShield 10.5\Redist\Language Independent\OS Independent

2 ibd files in this folder
IsDialogBanner.ibd ---> this is for the banner on the top of dialog
IsDialogBitmap.ibd----> for bitmap left-side of dialog

(2) Rename 2 ibd files for backup and name the banner / bitmap image to .ibd

Rename IsDialogBanner.ibd to IsDialogBanner_old.ibd or IsDialogBanner.ibd.bak

Name the bitmap or jpg image you want to display to  IsDialogBanner.ibd / IsDialogBitmap.ibd

(3) build the solution

[NOTE] the size of banner is 499x58 pixels and    bitmap is 499x312 pixels

Remember that background color of right side of bitmap should other than black, or you can't see the texts.

Installshield Restart after install/uninstall

在 Installation Designer' tab -> 'Behavior and Logic' -> 'Custom Actions and Sequences' -> 'Sequences' -> 'Installation' -> 'Execute' -> 'ScheduleReboot'
初始值是 ISSCHEDULEREBOOT

設定condition
(1) NOT REMOVE : 安裝完重開機
(2) REMOVE : Uninstall後restart
(3) NOT REMOVE AND REMOVE

如果不想看到重開機的提示
Go to 'Installation Designer' tab -> 'Behavior and Logic' -> 'Property Manager'

加入或修改

name : REBOOTPROMPT
value : Suppress

2011年3月28日 星期一

Installshield Combo box Property

在Installshield中的Dailog新增一個combo box

其中的property必須在"property Manager"中設為全域變數,即為大寫

否則將視為local property

From Installshield help library:

Enter the name of a property that will be set when the end user enters a value into or selects one from this combo box. This property can be unique to this combo box; it need not be present in the Property Manager.

To set a default value for this combo box, make the property is a public property by giving it a name containing only uppercase letters (for example, COMBOPROPERTY), go to the Property Manager and add the public property, and then assign to it the value of the default selection (see Items, above).

2011年3月25日 星期五

SendMessage , PostMessage

SendMessage 和 PostMessage可以將message傳送到一個特定的window
兩者的不同在於 SendMessage必須等到收方做完 PostMessage則是只送

首先要define一個ID 最好是不要重複
#define ID_CHANGE_BMP WM_USER+399

在送方的function
::PostMessage(GetParent()->m_hWnd,ID_CHANGE_BMP,(WPARAM)1,(LPARAM)NULL);

[NOTE]::PostMessage是Windows的function, PostMessage是MFC, 兩者的參數不同
WPARAM是 UINT_PTR。16 bits in Win 3.1, 32 in wind32
LPARAM LONG_PTR, 32

 @收方
Message Map:
ON_MESSAGE(ID_CHANGE_BMP, OnChangeBMP)


LRESULT CIPCamTreeView::OnChangeBMP(WPARAM wParam, LPARAM lParam)
{

    bChangeBmp(wParam);
    return 0;
}

2011年3月21日 星期一

CToolTipCtrl

CToolTipCtrl *m_pOSDToolTip;

OnCreate()
{
    if(!m_pOSDToolTip)
        {
            m_pOSDToolTip= new CToolTipCtrl();
            m_pOSDToolTip->Create(this);
            m_pOSDToolTip->AddTool(m_pFixRatio,_T("Fix Ratio")); // CBitmapButton * m_pFixRatio
            m_pOSDToolTip->AddTool(m_pSnapShot,_T("Snapshot"));
            m_pOSDToolTip->Activate(TRUE);
        }
}

PreTranslateMessage(MSG* pMsg)
{
  
    if(m_bDisplayOSD)
    m_pOSDToolTip->RelayEvent(pMsg);

    return CStatic::PreTranslateMessage(pMsg);
}

2011年3月16日 星期三

Change CStatic Font color

Create a CStatic control
RECT rect;
RECT rcParent;
GetClientRect(&rcParent);
rect.left = rcParent.left;
rect.right = rcParent.right - nBtnWidth;
rect.top = rcParent.top ;
rect.bottom = rcParent.top + nOSDHeight;

if(! m_pCaption)
        {
            m_pCaption = new CStatic();
            bRet |= m_pCaption->Create(NULL, WS_CHILD|WS_VISIBLE|SS_NOTIFY, rect, this , IDC_CAPTIONBAR);//
            if(csCameraName.IsEmpty()) csCameraName = _T("Untitled");
            m_pCaption->SetWindowTextW(csCameraName);
            /*CFont * font = new CFont;
            font->CreateFontW(22,0,0,0,FW_SEMIBOLD,false,false,0,CHINESEBIG5_CHARSET,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,DEFAULT_PITCH&FF_SWISS,_T("Arial"));
            m_pCaption->SetFont(font);*/
           
        }

Override WM_CTLCOLOR message
HBRUSH CVideo::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
    HBRUSH hbr = CStatic::OnCtlColor(pDC, pWnd, nCtlColor);
    COLORREF textColor = RGB(255,255,255);
    COLORREF bkColor = RGB(0,0,0);

       if(nCtlColor == CTLCOLOR_STATIC) //
    {

        pDC->SetTextColor(textColor);
       pDC->SetBkColor(bkColor); // 這裡的background color只限於text周圍, 並不是CStatic所create出來的整個rectangle

    hbr = CreateSolidBrush(bkColor);  // 這樣才會填滿整個retangle
       
    }

return hbr;

其中
  • CTLCOLOR_BTN    Button control
  • CTLCOLOR_DLG    Dialog box
  • CTLCOLOR_EDIT    Edit control
  • CTLCOLOR_LISTBOX    List-box control
  • CTLCOLOR_MSGBOX    Message box
  • CTLCOLOR_SCROLLBAR    Scroll-bar control
  • CTLCOLOR_STATIC    Static control


 或者可以指定要改哪個ID
    if(pWnd->GetDlgCtrlID() ==IDC_CAPTIONBAR)
    {
       
        pDC->SetTextColor(textColor);
        pDC->SetBkColor(bkColor);

    }

     return hbr;
}

OnEraseBkgnd

OnEraseBkgnd()
{

    pDC->SetBkColor(BKCOLOR);//BKCOLOR
    CRect rect;
    GetClientRect(rect);
    CBrush bkColor(RGB(190,190,190));
    pDC->FillRect(&rect,&bkColor);
}
Override :WM_ERASEBKGND message
利用FillRect函式在視窗大小改變時 將background重畫。

2011年3月11日 星期五

[MFC] Get Applcation file name

TCHAR szPath[MAX_PATH];
if( !GetModuleFileName(NULL, szPath, MAX_PATH ))
{
 printf("GetModuleFileName failed (%d)\n", GetLastError());
 return _T("");
}
CString strPath(szPath);
int nPos = strPath.ReverseFind('\\');
strPath = strPath.Left(nPos + 1);
或者
TCHAR szPathName[MAX_PATH] = { 0 };
TCHAR szDrive[_MAX_DRIVE] = { 0 };
TCHAR szDir[_MAX_DIR] = { 0 };
TCHAR szFname[_MAX_FNAME] = { 0 };
TCHAR szExt[_MAX_EXT] = { 0 };
(void)::GetModuleFileName( NULL, szPathName, MAX_PATH );
_splitpath( szPathName, szDrive, szDir, szFname, szExt );