ShowBalloonTip in Unicode modus lauffähig bekommen

Für allgemeine Fragen zur Programmierung mit PureBasic.
Benutzeravatar
ts-soft
Beiträge: 22292
Registriert: 08.09.2004 00:57
Computerausstattung: Mainboard: MSI 970A-G43
CPU: AMD FX-6300 Six-Core Processor
GraKa: GeForce GTX 750 Ti, 2 GB
Memory: 16 GB DDR3-1600 - Dual Channel
Wohnort: Berlin

Re: ShowBalloonTip in Unicode modus lauffähig bekommen

Beitrag von ts-soft »

Code: Alles auswählen

Structure IconData
  cbSize.l
  hwnd.l
  uID.l
  uFlags.l
  uCallbackMessage.l
  hIcon.l
  szTip.b[128]
  dwState.l
  dwStateMask.l
  szInfo.b[256]
  StructureUnion
  uTimeout.l
  uVersion.l
  EndStructureUnion
  szInfoTitle.b[64]
  dwInfoFlags.l
EndStructure

Procedure.w GetDataSize()
   Protected BuffSize.l, databuf.s, Result.i, nVerMajor.i, lpBuffer.i, puLen.l
   
  If OpenLibrary(1,"VERSION.DLL")
    BuffSize.l= CallFunction(1,"GetFileVersionInfoSizeW",@"shell32.dll",0)
    If BuffSize>0
      databuf.s=Space(BuffSize-1)
      ;Dim databuf.b(BuffSize-1)
      Result=CallFunction(1,"GetFileVersionInfoW",@"shell32.dll",0,BuffSize,@databuf)
      Result=CallFunction(1,"VerQueryValueW",@databuf,@"\",@lpBuffer,@puLen)
      CopyMemory(lpBuffer+10,@nVerMajor,2)
    EndIf
    CloseLibrary(1)
    Select nVerMajor
      Case 6
        ProcedureReturn #NOTIFYICONDATA_V3_SIZE
       
      Case 5
        ProcedureReturn #NOTIFYICONDATA_V2_SIZE
       
      Default
        ProcedureReturn #NOTIFYICONDATA_V1_SIZE
    EndSelect
  EndIf

EndProcedure

Procedure ShowBalloonTip(SystrayID.i, WindowHwnd.i,  title.s,maintext.s,tooltiptext.s,IconType.l)
  Protected Balloon.IconData\cbSize=GetDataSize(), Result.l, TempLib.i

  Balloon\hwnd = WindowHwnd
  Balloon\uId = SystrayID
  Balloon\uFlags =  #NIF_INFO | #NIF_MESSAGE | #NIF_ICON | #NIF_TIP
  Balloon\hIcon = ImageID(0)
  Balloon\dwState = #NIS_SHAREDICON
  Balloon\uCallbackMessage=#WM_USER
  Balloon\uTimeout = 30000
  If OSVersion() < #PB_OS_Windows_2000
    Balloon\uVersion = 0
  Else
    Balloon\uVersion = #NOTIFYICON_VERSION
  EndIf
  Balloon\dwInfoFlags = IconType

  If Balloon.IconData\cbSize=#NOTIFYICONDATA_V1_SIZE
    PokeS(@Balloon\szTip, tooltiptext,64, #PB_Ascii)
  Else
    PokeS(@Balloon\szTip, tooltiptext,128, #PB_Ascii)
    PokeS(@Balloon\szInfo,maintext.s,255, #PB_Ascii)
    PokeS(@Balloon\szInfoTitle,title.s,63, #PB_Ascii)
  EndIf
  TempLib = OpenLibrary(#PB_Any,"shell32.dll")
  Result= CallFunction(TempLib,"Shell_NotifyIcon",#NIM_MODIFY,@Balloon)
  CloseLibrary(TempLib)
EndProcedure

If OpenWindow(0, 100, 150, 300, 100, "PureBasic - SysTray Example", #PB_Window_SystemMenu)

  IconName$ = #PB_Compiler_Home+"Examples\Sources\Data\CdPlayer.ico"

 
  AddSysTrayIcon(1, WindowID(0), LoadImage(0, IconName$))

  ShowBalloonTip(1, WindowID(0), "Title", "Text", "Tooltiptext", #NIIF_USER)
 
  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow
 
EndIf 
PureBasic 5.73 LTS | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Nutella hat nur sehr wenig Vitamine. Deswegen muss man davon relativ viel essen.
Bild
Benutzeravatar
ts-soft
Beiträge: 22292
Registriert: 08.09.2004 00:57
Computerausstattung: Mainboard: MSI 970A-G43
CPU: AMD FX-6300 Six-Core Processor
GraKa: GeForce GTX 750 Ti, 2 GB
Memory: 16 GB DDR3-1600 - Dual Channel
Wohnort: Berlin

Re: ShowBalloonTip in Unicode modus lauffähig bekommen

Beitrag von ts-soft »

Sirhc.ITI hat geschrieben:Wen du mir jetzt noch sagst wieso das nicht als x64 läuft bin ich zufrieden <)
Hab leider keine Infos zu diesem Code, scheint auf Try & Error zu basieren, läuft nur unter sehr
eingeschränkten Bedingungen. Hab damit schon vor ein paar Monaten mal gespielt, ohne Ergebnis.

Gruß
Thomas
PureBasic 5.73 LTS | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Nutella hat nur sehr wenig Vitamine. Deswegen muss man davon relativ viel essen.
Bild
Benutzeravatar
jpd
Beiträge: 380
Registriert: 14.02.2005 10:33

Re: ShowBalloonTip in Unicode modus lauffähig bekommen

Beitrag von jpd »

Hallo Sirhc.ITI,

ich habe einige zeit her die gleiche Problematik mit der SysTrayEx Library 1.0 von flype gehabt, damals habe ich die Unicode fähig gemacht.
Habe nun diese angepasst so das diese auch unter x64bit funktioniert.

Hier ein Link zur flype alte lib Flype UserLibraries for PureBasic 4.0

ich glaube das mittlerweile flype nicht mehr so aktiv ist und seine libs nicht mehr pflegt, echt schade :cry:

und hier ein link zur neue SysTrayEx Lib 1.2 habe diese mit PB 4.51 64bit und PB 4.51/4.60b3 32bit.

SysTrayEx 1.2

ich denke das es für dich kein Problem sein wird die dort verwendete "Structur" in deinen Beispiel zu übernehmen. :)

Ciao
jpd
PB 5.10 Windows 7 x64
Benutzeravatar
ts-soft
Beiträge: 22292
Registriert: 08.09.2004 00:57
Computerausstattung: Mainboard: MSI 970A-G43
CPU: AMD FX-6300 Six-Core Processor
GraKa: GeForce GTX 750 Ti, 2 GB
Memory: 16 GB DDR3-1600 - Dual Channel
Wohnort: Berlin

Re: ShowBalloonTip in Unicode modus lauffähig bekommen

Beitrag von ts-soft »

:allright: Die Strukture sieht ja mal ganz anders aus :wink:
PureBasic 5.73 LTS | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Nutella hat nur sehr wenig Vitamine. Deswegen muss man davon relativ viel essen.
Bild
Benutzeravatar
jpd
Beiträge: 380
Registriert: 14.02.2005 10:33

Re: ShowBalloonTip in Unicode modus lauffähig bekommen

Beitrag von jpd »

Hallo Sirhc.ITI,

habe die "structure" nochmal angepasst da es unter xp und 2000 nicht mehr funktionierte .. nun schon! :)

Ciao
jpd

Code: Alles auswählen

Structure NOTIFYICONDATA_95
    cbSize.l
    CompilerIf #PB_Compiler_Processor = #PB_Processor_x64
    PB_Alignment1.b[4]
  CompilerEndIf
  hwnd.i
  uID.l
  uFlags.l
  uCallbackMessage.l
  CompilerIf #PB_Compiler_Processor = #PB_Processor_x64
    PB_Alignment2.b[4]
  CompilerEndIf
  hIcon.i
  szTip.c[64]
EndStructure
Structure NOTIFYICONDATA_2K Extends NOTIFYICONDATA_95
  szTipEx.c[64]
  dwState.l
  dwStateMask.l
  szInfo.c[256]
  StructureUnion
  uTimeout.l
  uVersion.l
  EndStructureUnion
  szInfoTitle.c[64]
  dwInfoFlags.l
EndStructure
Structure NOTIFYICONDATA_XP Extends NOTIFYICONDATA_2K
    guid.GUID
    ;hBalloonIcon.i
EndStructure     
Structure NOTIFYICONDATA_VISTA Extends NOTIFYICONDATA_XP
    ;guid.GUID
    hBalloonIcon.i
EndStructure  
Procedure ShowBalloonTip(SystrayID.i, hWindow.i, title.s, message.s, timeOut.i, IconType.i, Iconh.i=0)
   
  Protected nid.NOTIFYICONDATA_2K
 
  If OSVersion() >= #PB_OS_Windows_Vista
      nid\cbSize = SizeOf(NOTIFYICONDATA_VISTA)
    ElseIf OSVersion() >= #PB_OS_Windows_XP
      nid\cbSize = SizeOf(NOTIFYICONDATA_XP)
      
    ElseIf OSVersion() >= #PB_OS_Windows_2000
      nid\cbSize = SizeOf(NOTIFYICONDATA_2K)
      
    Else
        ProcedureReturn #False
    EndIf
 
  nid\uVersion = #NOTIFYICON_VERSION
  Shell_NotifyIcon_(#NIM_SETVERSION, @nid)
 
  nid\uID                  = SystrayID
  nid\hwnd                    = hWindow
  nid\dwInfoFlags          = IconType
  nid\uFlags               = #NIF_INFO | #NIF_MESSAGE | #NIF_ICON | #NIF_TIP
  nid\hIcon                     = Iconh
  nid\dwState                = #NIS_SHAREDICON
  nid\uCallbackMessage   =   #WM_USER
  nid\uTimeout             = timeOut
 
 
  PokeS(@nid\szInfo, message, 256)
  PokeS(@nid\szInfoTitle, title, 64)
 
  ProcedureReturn Shell_NotifyIcon_(#NIM_MODIFY, @nid)

EndProcedure

If OpenWindow(0, 100, 150, 300, 100, "PureBasic - SysTray Example", #PB_Window_SystemMenu)

  IconName$ = #PB_Compiler_Home+"Examples\Sources\Data\CdPlayer.ico"

  AddSysTrayIcon(1, WindowID(0), LoadImage(0, IconName$))

  ShowBalloonTip(1, WindowID(0), "Title", "Text", 5000, #NIIF_USER, ImageID(0))

  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow

EndIf 
PB 5.10 Windows 7 x64
Benutzeravatar
Danilo
-= Anfänger =-
Beiträge: 2284
Registriert: 29.08.2004 03:07

Re: ShowBalloonTip in Unicode modus lauffähig bekommen

Beitrag von Danilo »

Sirhc.ITI hat geschrieben:Hi, Ich hab ein Problem mit dem Code, nachdem der Balloontip erscheint kommen keine Systray events mehr an.
Wenn Du das Flag #NIF_MESSAGE entfernst geht es wieder.

Code: Alles auswählen

  nid\uFlags               = #NIF_INFO | #NIF_ICON | #NIF_TIP ;| #NIF_MESSAGE
  ;nid\uCallbackMessage   =   #WM_USER
Da Du eh keinen Callback hast, brauchst Du das wohl auch nicht.

Hier noch eine kleine Fehlerbehebung, was mir aufgefallen ist:

Code: Alles auswählen

  PokeS(@nid\szInfo, message, 256-SizeOf(Character)) 
  PokeS(@nid\szInfoTitle, title, 64-SizeOf(Character))
PokeS schreibt 'Length' Zeichen plus die 0 ans Ende.
Wenn Du also 256 & 64 angibst, schreibt PB 257 & 65 Zeichen inkl. der 0.
Also 1 Zeichen abziehen für die 0.
cya,
...Danilo
"Ein Genie besteht zu 10% aus Inspiration und zu 90% aus Transpiration" - Max Planck
Antworten