News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

TB_GETRECT

Started by bomz, May 04, 2011, 08:21:43 PM

Previous topic - Next topic

bomz



I want this - but it was vary hard to do because system fatal crashes after each examination. and now I want be shure that all OK

baltoro

YOU'RE RUSSIAN ! Why didn't you say so ???
We have a Russian-speaking programmer here on the Forum,...and, he is alot better at this than I am,...
Baltoro

qWord

For assigning an ToolTip to the task bar, it's probably needed to to inject a DLL in Explorers process. For an general solution this also implies, that you must at least create two DLLs: 32Bit and 64Bit.
However, DLL injection is an topic, that's not allowed to discuss in this forum.
FPU in a trice: SmplMath
It's that simple!

dedndave

i think i can understand why he wants the icon position
the fact that he is Russian makes it hard for him to verbalize it, is all   :P

baltoro

#19
Thank God you guys showed up,...I'm afraid I've badly misled the guy,... :green
...And, to be perfectly honest,...I'm quite confused about the whole thing,...
Baltoro

donkey

From what I understand you are just trying to get the rect for the icon. The function for that is Shell_NotifyIconGetRect. Win7 and above though.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

Tedd

You guys worry me ::)

No snowflake in an avalanche feels responsible.

qWord

Tedd, he was talking about adding an ToolTip to the Icon of Mozilla Firefox (AFAIKS)
FPU in a trice: SmplMath
It's that simple!

baltoro

...Ya know,...I didn't quite get it either,...he has the phrase 'Mozilla Firefox' in his code, but, it doesn't make sense.
Also, one of his responses was:
Quote from: BOMZ...The problem in correct manipulate with explorer memory,...
which confused the hell out of me. I don't think he knew himself. But, he didn't approach the problem by calling Shell functions,...which is what I would have done,...instead, he calls FindWindowEx using a Hwnd that is probably Null,...hell, we don't even know that,...
...And, I didn't recognize the names he listed in his original code for the Window Class Names as registered system names,...
Class1      db 'Shell_TrayWnd',0
Class2      db 'TrayNotifyWnd',0
Class3      db 'SysPager',0
Class4      db 'ToolbarWindow32',0


I actually googled those phrases, and I found several forum references to them in various places,...but, one was a NET type, one was VB,..

BOMZ,...are you out there ???
Baltoro

bomz

I am talking about - why error in this string, I don't say anything what I am doing. Mozilla I signed to show that this icon realy exist and it's not antivirus.

NEXT:
;   dec IconNumber
   mov IconNumber, 0 ;Mozilla Firefox

;cmp IconNumber,0
;jnz NEXT

I don't understand that memory must be double readed

baltoro

But, you are referring to the Windows desktop and not Internet Explorer ???
Baltoro

bomz

Yes. any IE
You see level of my English: "memory context" - this may be understood very different

System crashes, after 2 hour I hope for help

baltoro

Yes,...I can see it is difficult for you. Well, thank God, you aren't trying to decipher my Russian,...because,...it would be alot worse.
So, my next question is: How can you be sure you have the correct Window handle for the running Internet Explorer instance ???
Baltoro

bomz

as I understand you right - for My process (application) I do this by HWND, for IE need ID of process with name iexplorere.exe

bomz

Quote
PopupProc   PROTO :DWORD,:DWORD

EXTRADATA struct
        Wnd dd ?
        uID dd ?
EXTRADATA ends
............................................................
Class1         db 'Shell_TrayWnd',0
Class2         db 'TrayNotifyWnd',0         ; область уведомлений
Class3         db 'SysPager',0
Class4         db 'ToolbarWindow32',0
TOOLTIPS_CLASS      db "tooltips_class32",0
...............................................

invoke PopupProc, MsgPopup, hWnd

...............................................

PopupProc proc   PopupText:DWORD, HWnD:HWND
LOCAL      rect:RECT
LOCAL      toolinfo:TOOLINFO
LOCAL      extra:EXTRADATA
LOCAL      button:TBBUTTON
LOCAL      rect1:RECT
LOCAL      ToolbarHandle:HWND
LOCAL      ProcId:DWORD
LOCAL      hProcess:DWORD
LOCAL      lpData:DWORD
LOCAL      lpData1:DWORD
LOCAL      IconNumber:DWORD
LOCAL      ProcTrayId:DWORD
LOCAL      ButtonID:DWORD

   invoke FindWindow,addr Class1, NULL
   test eax, eax
   jz NoHandle
   mov ToolbarHandle, eax
   invoke FindWindowEx,eax,NULL,addr Class2, NULL
   test eax, eax
   jz NoHandle
   mov ToolbarHandle, eax
   invoke FindWindowEx,eax,NULL,addr Class3, NULL
   test eax, eax
   jz NoHandle
   mov ToolbarHandle, eax
   invoke FindWindowEx,eax,NULL,addr Class4, NULL
   test eax, eax
   jz NoHandle
   mov ToolbarHandle, eax
   invoke  SendMessage,ToolbarHandle,TB_BUTTONCOUNT,0,0
   test eax, eax
   jz NoHandle
   mov IconNumber, eax
   invoke  GetWindowThreadProcessId,ToolbarHandle,addr ProcId
   test eax, eax
   jz NoHandle
   invoke  OpenProcess,PROCESS_ALL_ACCESS,FALSE,ProcId
   test eax, eax
   jz NoHandle
   mov hProcess,eax
   invoke  VirtualAllocEx,hProcess,NULL,sizeof button,MEM_COMMIT,PAGE_READWRITE
   test eax, eax
   jz NoMemory
         mov lpData, eax
   invoke  VirtualAllocEx,hProcess,NULL,sizeof rect1,MEM_COMMIT,PAGE_READWRITE
   test eax, eax
   jz NoMemory1
         mov lpData1, eax
NEXT:
   dec IconNumber
   invoke  SendMessage,ToolbarHandle,TB_GETBUTTON,IconNumber,lpData
   invoke  ReadProcessMemory, hProcess, lpData,addr button, sizeof button, addr bytesRead
   invoke  ReadProcessMemory,hProcess,button.dwData,addr extra, sizeof extra,addr bytesRead
   mov eax, extra.Wnd
   cmp eax, HWnD
   je found10

   cmp IconNumber,0
   jnz NEXT
   jmp NoFound
found10:
   invoke  SendMessage,ToolbarHandle,TB_GETRECT, button.idCommand, lpData1
   invoke  ReadProcessMemory, hProcess, lpData1,addr rect1, sizeof rect1, addr bytesRead
NoFound:
   invoke  VirtualFreeEx,ProcId,lpData1,0,MEM_RELEASE
NoMemory1:
   invoke  VirtualFreeEx,ProcId,lpData,0,MEM_RELEASE
NoMemory:
   invoke  CloseHandle,ProcId
NoHandle:
   invoke GetWindowRect, ToolbarHandle,addr rect
   mov eax, rect1.top
   inc eax
   add rect.top, eax
   mov eax, rect1.left
   inc eax
   add rect.left, eax

   invoke sndPlaySound, addr SoundPopup, SND_SYNC
   invoke WindowFromPoint,rect.right,rect.top
   push eax
   invoke CreateWindowEx,WS_EX_TOPMOST,ADDR TOOLTIPS_CLASS,NULL,\
   TTS_ALWAYSTIP or TTS_BALLOON,CW_USEDEFAULT, CW_USEDEFAULT,\
   CW_USEDEFAULT,CW_USEDEFAULT,HWnD,NULL,hInstance,NULL
   mov hToolTips,eax
   mov toolinfo.cbSize,sizeof TOOLINFO
   mov toolinfo.uFlags,TTF_IDISHWND or TTF_TRACK
   mov toolinfo.hWnd,NULL
   pop toolinfo.uId
   mov toolinfo.hInst,NULL
   push PopupText
   pop toolinfo.lpszText
   invoke SendMessage,hToolTips,TTM_ADDTOOL,0,addr toolinfo
   invoke SendMessage,hToolTips,TTM_SETMAXTIPWIDTH,0,500
   invoke SendMessage,hToolTips,TTM_SETTITLE,1,addr ToolTipsCaption
   mov ecx,rect.top
   shl ecx,10h
   mov eax,rect.left
   or ecx,eax
   invoke SendMessage,hToolTips,TTM_TRACKPOSITION,0,ecx
   invoke SendMessage,hToolTips,TTM_TRACKACTIVATE,TRUE,addr toolinfo
   ret

PopupProc endp