Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

please help in creating tray icon for dialog box

i am not able to implement tray icon for my dialog boxt..can u provide me with some code...here's my code or a dialog box now i want to make a tray icon for this..please provide help in coding for this...thanks





//---------------------------------------------------------------------------
LPSTR lpString;
HWND hWnd;

LRESULT CALLBACK DlgProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
//---------------------------------------------------------------------------
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow)
{
DialogBox(hInstance, MAKEINTRESOURCE(IDD_DLGFIRST),hWnd, reinterpret_cast(DlgProc));
return FALSE;
}




//---------------------------------------------------------------------------
LRESULT CALLBACK DlgProc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
{
TCHAR cPath[20];
TCHAR cUserName[20];
TCHAR cPassword[20];
switch(Msg)
{
case WM_INITDIALOG:
{
return TRUE;
}

case WM_COMMAND:
{
switch(wParam)
{
case IDOK:
{
size_t nLen;
GetDlgItemText(hWndDlg, IDC_EDIT1, cPath, 20);
nLen = strlen(cPath);
if (nLen == 0)
{
MessageBox(hWndDlg,"Please Enter SVN Path","Error",MB_ICONERROR);
break;
}
GetDlgItemText(hWndDlg, IDC_EDIT2, cUserName, 20);
nLen = strlen(cUserName);
if (nLen == 0)
{
MessageBox(hWndDlg,"Please Enter your user name","Error",MB_ICONERROR);
break;
}
GetDlgItemText(hWndDlg, IDC_EDIT3, cPassword, 20);
nLen = strlen(cPath);
if (nLen == 0)
{
MessageBox(hWndDlg,"Please Enter your Password ","Error",MB_ICONERROR);
break;
}
EndDialog(hWndDlg, 0);
std::ofstream file ("config.txt");
file << " SVN Path entered by user is -> "<<cPath << std::endl;
file << " SVN User name entered by User ->" <<cUserName << std::endl;
file << " SVN Password Entered by User ->"<<cPassword << std::endl;
file.close();
}


case IDCANCEL:
{
EndDialog(hWndDlg, 0);
return TRUE;
break;
}
}
return FALSE;
}
}
return 0;
}


please help me out..

Comments

  • BitByBit_ThorBitByBit_Thor Member Posts: 2,444
    Here's the MSDN page on the function used to register a tray icon: http://msdn2.microsoft.com/en-us/library/ms647738.aspx

    Best Regards,
    Richard

    The way I see it... Well, it's all pretty blurry
  • dona jaindona jain Member Posts: 9
    : Here's the MSDN page on the function used to register a tray icon:
    : http://msdn2.microsoft.com/en-us/library/ms647738.aspx
    :
    : Best Regards,
    : Richard
    :
    : The way I see it... Well, it's all pretty blurry


    thanx for ur help..i knew this function but i m getting problem in implementing it in my program..i do not unmderstand where to initialize it..it will very nice of u if u please edit the code i hav given you by adding lines of cide used to make tray icon for it..

    thanx in advance
  • BitByBit_ThorBitByBit_Thor Member Posts: 2,444
    This site should give you more insight:

    http://www.codeproject.com/shell/StealthDialog.asp
    Best Regards,
    Richard

    The way I see it... Well, it's all pretty blurry
  • dona jaindona jain Member Posts: 9
    : This site should give you more insight:
    :
    : http://www.codeproject.com/shell/StealthDialog.asp
    : Best Regards,
    : Richard
    :
    : The way I see it... Well, it's all pretty blurry

    thanks..i succeeded in making tray icon..bur how to minimize it to tray only when i click on minimize button.also after filling all three field which are asked and then when i press ok i want the dialog window to minimize to taskbar icon..please help me...my code is as follows:


    #include
    #include "resource.h"
    #include
    #include
    #include
    #include
    #include
    #include "FileOperation.h"
    #include
    #define WM_ICON_NOTIFY WM_USER+1




    //---------------------------------------------------------------------------
    LPSTR lpString;
    HWND hWnd;

    LRESULT CALLBACK DlgProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
    //---------------------------------------------------------------------------
    INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,LPSTR lpCmdLine, int nCmdShow)
    {
    DialogBox(hInstance, MAKEINTRESOURCE(IDD_DLGFIRST),hWnd, reinterpret_cast(DlgProc));
    return FALSE;
    }


    //---------------------------------------------------------------------------
    LRESULT CALLBACK DlgProc(HWND hWndDlg, UINT Msg, WPARAM wParam, LPARAM lParam)
    {

    char cPath[20];
    char cUserName[20];
    char cPassword[20];
    switch(Msg)
    {

    case WM_INITDIALOG:
    {
    }

    case WM_ICON_NOTIFY:
    {
    }
    case WM_LBUTTONDBLCLK:
    {
    ShowWindow(hWndDlg, IDD_DLGFIRST);
    break;
    }


    break;

    case WM_COMMAND:
    {

    switch(wParam)
    {

    case IDOK:
    {
    size_t nLen;
    GetDlgItemText(hWndDlg, IDC_EDIT1, cPath, 20);
    nLen = strlen(cPath);
    if (nLen == 0)
    {
    MessageBox(hWndDlg,"Please Enter SVN Path","Error",MB_ICONERROR);
    break;
    }
    GetDlgItemText(hWndDlg, IDC_EDIT2, cUserName, 20);
    nLen = strlen(cUserName);
    if (nLen == 0)
    {
    MessageBox(hWndDlg,"Please Enter your user name","Error",MB_ICONERROR);
    break;
    }
    GetDlgItemText(hWndDlg, IDC_EDIT3, cPassword, 20);
    nLen = strlen(cPassword);
    if (nLen == 0)
    {
    MessageBox(hWndDlg,"Please Enter your Password ","Error",MB_ICONERROR);
    break;
    }
    /*EndDialog(hWndDlg, 0);*/

    /*std::ofstream file ("config.txt");
    file << " SVN Path entered by user is -> "<<cPath << std::endl;
    file << " SVN User name entered by User ->" <<cUserName << std::endl;
    file << " SVN Password Entered by User ->"<<cPassword << std::endl;
    file.close();*/

    FileOperation fcWrite;
    fcWrite.fileOpen( cPath ,cUserName ,cPassword);
    NOTIFYICONDATA ndata;
    ndata.cbSize=sizeof(NOTIFYICONDATA);
    ndata.hWnd=hWndDlg;
    ndata.uID=0;
    ndata.uFlags=NIF_ICON|NIF_MESSAGE|NIF_TIP;
    ndata.uCallbackMessage=WM_ICON_NOTIFY;
    ndata.hIcon = LoadIcon(GetModuleHandle(NULL),MAKEINTRESOURCE(IDI_ICON1));
    strcpy(ndata.szTip,"SVN Log Viewer");
    Shell_NotifyIcon(NIM_ADD,&ndata);
    ShowWindow(hWndDlg, IDD_DLGFIRST);
    UpdateWindow(hWndDlg);
    //ShowWindow(hWndDlg, IDD_DLGFIRST);

    break;
    //SetWindowPos(hWndDlg,NULL,-300,-300,340,340,SWP_NOZORDER|SWP_NOMOVE);
    //SetWindowPos(hWndDlg,NULL,10,10,0,0,SWP_NOZORDER|SWP_NOMOVE);





    }



    /*case WM_LBUTTONDBLCLK:
    {
    ShowWindow(hWndDlg, IDD_DLGFIRST);
    break;
    }*/

    case IDCANCEL:
    {
    EndDialog(hWndDlg, 0);
    return TRUE;
    break;
    }

    }
    return FALSE;
    }
    }
    return 0;
    }




  • BitByBit_ThorBitByBit_Thor Member Posts: 2,444

    : thanks..i succeeded in making tray icon..bur how to minimize it to
    : tray only when i click on minimize button.

    Handle the appropriate window message for minimization: WM_SIZE
    http://msdn2.microsoft.com/en-us/library/ms632646.aspx

    : also after filling all
    : three field which are asked and then when i press ok i want the
    : dialog window to minimize to taskbar icon..

    Just hide your Dialog Window after setting up the icon.


    Best Regards,
    Richard

    The way I see it... Well, it's all pretty blurry
Sign In or Register to comment.