Announcement

Collapse
No announcement yet.

Fast add an icon to the tray?..

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Lance Edmonds
    replied
    Don't quote me on this (I may be wrong), but the highest message used by the common and standard controls seems to be below %WM_USER + 300.

    In your code above, the %WM_TRAYICON = (%WM_USER + 400) should be fine, but you should also change the PostMessage() and CASE %WM_USER to use a higer value, ie, (%WM_USER + 401).

    As discussed in above, adding %WS_MINIMIZE to the dialog style for the initial dialog may be useful to stop the "flash" of the dialog as the app starts. Either that, or make the dialog look like a splash screen as it starts.


    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>

    Leave a comment:


  • Alexander Doc
    Guest replied
    Lance --

    I use %WM_USER + 400 ... is it OK?
    and DIALOG SHOW STATE by ...CASE %WM_USER in function
    DialogProc make no error. Is it mistake???:
    ...
    %WM_TRAYICON = %WM_USER + 400
    ...
    FUNCTION DialogProc(BYVAL hDlg AS LONG, BYVAL wMsg AS LONG, _
    BYVAL wParam AS LONG, BYVAL lParam AS LONG) AS LONG
    STATIC hMenu AS LONG
    STATIC ti AS NOTIFYICONDATA
    STATIC p AS POINTAPI

    SELECT CASE wMsg

    CASE %WM_INITDIALOG
    ' Get Menu Handle
    dumm&=PostMessage(hDlg, %WM_USER, 0, 0)
    hMenu = GetSubMenu(LoadMenu(sdDialog, "POPUPMENU"), 0)

    ' Add tray icon
    ti.cbSize = SIZEOF(ti)
    ti.hWnd = hDlg
    ti.uID = sdDialog
    ti.uFlags = %NIF_ICON OR %NIF_MESSAGE OR %NIF_TIP
    ti.uCallbackMessage = %WM_TRAYICON
    ti.hIcon = LoadIcon(sdDialog, "...")
    ti.szTip = "..."
    Shell_NotifyIcon %NIM_ADD, ti
    DestroyIcon ti.hIcon
    FUNCTION = 1

    CASE %WM_USER
    DIALOG SHOW STATE hDlg, %SW_HIDE

    CASE %WM_TRAYICON

    SELECT CASE LOWRD(lParam)

    ' Right button press
    CASE %WM_RBUTTONDOWN
    IF IsWindowVisible(hDlg) = %FALSE THEN
    SetForegroundWindow hDlg
    GetCursorPos p
    TrackPopupMenu hMenu, 0, p.x, p.y, 0, hDlg, _
    BYVAL %NULL
    Postmessage hDlg, %WM_NULL, 0, 0
    END IF

    END SELECT
    ....
    ...
    _________
    Alexander
    [email protected]et


    ------------------

    Leave a comment:


  • Lance Edmonds
    replied
    You can't use DIALOG SHOW STATE in %WM_INITDIALOG as the DDT engine has not finished setting up the dialog at that point. That is the reason for the PostMessage() call, so that the "hide" code gets executed after the remaining setup is completed.

    One footnote: some controls send notification messages that conflict with %WM_USER, so it may be better to use (%WM_USER + 700) or use RegisterWindowMessage() to create a private message that is guaranteed not to conflict. This requires at least one STATIC variable to hold the message value between iterations of the callback.


    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>

    Leave a comment:


  • Rick Hays
    replied
    Alexander,
    Not sure about the WM_USER, but I did try the SHOW STATE under the WM_INITDIALOG and that did not work... The best way is to not do it in DDT... That way you have full control over the Dialog.

    ------------------
    Mr. Nobody aka Rick Hays
    mailto:[email protected][email protected]</A>
    http://www.nowhereville.com


    Leave a comment:


  • Alexander Doc
    Guest replied
    Eric-- & Rick--

    I have better Idea of Lance Edmonds:
    ... in response to a %WM_INITDIALOG message in your dialog callback, use PostMessage() to send the dialog a %WM_USER message. In response to the %WM_USER message, perform a DIALOG SHOW STATE statement.

    {...
    Case %WM_INITDIALOG
    .....
    dumm& = PostMessage(hDlg, %WM_USER, 0, 0)

    Case %WM_USER
    DIALOG SHOW STATE hDlg, %SW_HIDE
    {...

    Regards,
    Alexander



    ------------------

    Leave a comment:


  • Eric Pearson
    replied
    Rick --

    That's why I couldn't find the thread I was looking for, we talked via email.

    The solution is this...

    If you use the %WS_MINIMIZED style in your DIALOG NEW statement, the dialog will appear minimized when you execute DIALOG SHOW. And if you also use the %WS_EX_TOOLWINDOW extended style, which creates a dialog without a Task Bar button, then nothing at all will appear on the screen when you use DIALOG SHOW.

    The only problem is that if you click the Sys Tray icon and show the dialog, a Task Bar button will not appear. But you could get around that too, by using the original toolwindow dialog as a "dummy" window for the receipt of Sys Tray icon clicks, and when they are received, use DIALOG NEW to create an all-new dialog that does have a Task Bar button.

    -- Eric


    ------------------
    Perfect Sync: Perfect Sync Development Tools
    Email: mailto:[email protected][email protected]</A>

    Leave a comment:


  • Rick Hays
    replied
    first off... eric, you did not give me that idea of having it displayed off the screen at 10000,10000... you made me have to think.. har har har )

    ok if it was the time i asked about how to do this then the pointer is...
    http://www.powerbasic.com/support/pb...ad.php?t=14320

    not sure if that will be of great help cause eric and i took it too private emails after a bit... if an example is needed then i could whip up something pretty quick to show the process.. let me know...

    ------------------
    mr. nobody aka rick hays
    mailto:[email protected][email protected]</a>
    http://www.nowhereville.com


    Leave a comment:


  • Eric Pearson
    replied
    Alexander --

    If all you want to do is keep a DDT-created dialog from showing, you should be able to specify a screen location that is not visible to the user, like 10000,10000.

    If you also want to hide the Task Bar button, that is a little more complicated. It was discussed in a recent thread, and it can be done, but I can't seem to find the thread. If I have time later I'll look some more, but maybe somebody will remember it and will post the thread's forum and name...

    -- Eric

    ------------------
    Perfect Sync: Perfect Sync Development Tools
    Email: mailto:[email protected][email protected]</A>



    [This message has been edited by Eric Pearson (edited February 17, 2000).]

    Leave a comment:


  • Rick Hays
    replied
    If I understand what you are trying todo is to add the ICON to the tray but not display the Dialog?

    You can't do this with the DDT, you have to build your Dialog with the Dialog Editor and not set the Dialog Flag (WS_VISIBLE) to Display, then Compile it with the Resource Editor. Thats how I had to do it... For me it was a learning curve to learn the in's and outs of building a Dialog this way but it was time well spent.. )

    Hope this helps point you in the right direction.

    ------------------
    Mr. Nobody aka Rick Hays
    mailto:[email protected][email protected]</A>
    http://www.nowhereville.com


    Leave a comment:


  • Alexander Doc
    Guest started a topic Fast add an icon to the tray?..

    Fast add an icon to the tray?..

    Hello!
    How immediately with program start add an icon to the tray (with popupmenu)? without show the dialog?
    The DDT engine sets the WS_VISIBLE style for each dialog, if you want or not. (...in example Tray.bas)
    Please, help me.

    Thanks

    Alexander
Working...
X