1. SendMessage Returns a Value?
- Posted by euphoric <euphoric at cklester.com> Mar 23, 2004
- 441 views
I've looked up SendMessage info at msdn, but can't find return values for success/fail. Does anybody know how to determine if the message was sent or received properly? Here's the snippet of code I'm using... -- call AddFontResource if AddFontResource != -1 then junk = allocate_string( "free000.ttf" ) if xSendMessage!= -1 then fonter = c_func( AddFontResource, { junk } ) if fonter != 0 then junk = c_func(xSendMessage,{HWND_BROADCAST, WM_FONTCHANGE, 0, 0}) -- RIGHT HERE... HOW DO I DETERMINE IF xSendMessage completed properly? didAddFontResource = (1=1) else errMsg = "AddFontResource failed." end if else errMsg = "Could not access SendMessage." end if free(junk) else errMsg = "Could not access AddFontResource." end if
2. Re: SendMessage Returns a Value?
- Posted by Evan Marshall <1evan at sbcglobal.net> Mar 23, 2004
- 429 views
From the SDK: The return value specifies the result of the message processing; it depends on the message sent. It appears that a WM_FONTCHANGE message will return 0. Maybe SendMessage will return 0 for any message unless you specify a different value? i.e. if uMsg = WM_FONTCHANGE then return 100 end if will return 100 as a result whereas if uMsg = WM_FONTCHANGE then end if returns 0 C. K. Lester wrote: > > I've looked up SendMessage info at msdn, but can't find return values > for success/fail. Does anybody know how to determine if the message > was sent or received properly? > > Here's the snippet of code I'm using... > > -- call AddFontResource > if AddFontResource != -1 then > junk = allocate_string( "free000.ttf" ) > if xSendMessage!= -1 then > fonter = c_func( AddFontResource, { junk } ) > if fonter != 0 then > junk = c_func(xSendMessage,{HWND_BROADCAST, > WM_FONTCHANGE, 0, 0}) > -- RIGHT HERE... HOW DO I DETERMINE IF xSendMessage completed properly? > didAddFontResource = (1=1) > else > errMsg = "AddFontResource failed." > end if > else > errMsg = "Could not access SendMessage." > end if > free(junk) > else > errMsg = "Could not access AddFontResource." > end if > > > > For Topica's complete suite of email marketing solutions visit: > http://www.topica.com/?p=TEXFOOTER > >
3. Re: SendMessage Returns a Value?
- Posted by EUPHORiCK <euphoric at cklester.com> Mar 23, 2004
- 442 views
Bernie Ryan wrote: >SendMessageA() return values are determined by what >message is sent so you have to LOOK at the MESSAGE you >are sending at MSDN to see what is returned. You can >not assume zero is always sucessful. > > I did look at the message (WM_FONTCHANGE), and there's no return value list! >Have you looked at my windows library it might make your job easier. > > Yes, and it did. Thanks.
4. Re: SendMessage Returns a Value?
- Posted by Evan Marshall <1evan at sbcglobal.net> Mar 23, 2004
- 452 views
No. I see now that WM_FONTCHANGE returns 0, others may return handles or TRUE, etc. Evan Marshall wrote: > > From the SDK: The return value specifies the result of the message > processing; it depends on the message sent. > > It appears that a WM_FONTCHANGE message will return 0. Maybe > SendMessage will return 0 for any message unless you specify a > different value? > > i.e. > > if uMsg = WM_FONTCHANGE then > return 100 > end if > > will return 100 as a result > > whereas > > if uMsg = WM_FONTCHANGE then > end if > > returns 0 > > > C. K. Lester wrote: > >> >> I've looked up SendMessage info at msdn, but can't find return values >> for success/fail. Does anybody know how to determine if the message >> was sent or received properly? >> >> Here's the snippet of code I'm using... >> >> -- call AddFontResource >> if AddFontResource != -1 then >> junk = allocate_string( "free000.ttf" ) >> if xSendMessage!= -1 then >> fonter = c_func( AddFontResource, { junk } ) >> if fonter != 0 then >> junk = c_func(xSendMessage,{HWND_BROADCAST, >> WM_FONTCHANGE, 0, 0}) >> -- RIGHT HERE... HOW DO I DETERMINE IF xSendMessage completed properly? >> didAddFontResource = (1=1) >> else >> errMsg = "AddFontResource failed." >> end if >> else >> errMsg = "Could not access SendMessage." >> end if >> free(junk) >> else >> errMsg = "Could not access AddFontResource." >> end if >> >> >> For Topica's complete suite of email marketing solutions visit: >> http://www.topica.com/?p=TEXFOOTER >> >> > > > For Topica's complete suite of email marketing solutions visit: > http://www.topica.com/?p=TEXFOOTER > >
5. Re: SendMessage Returns a Value?
- Posted by euphoric <euphoric at cklester.com> Mar 23, 2004
- 429 views
Evan Marshall wrote: > > No. I see now that WM_FONTCHANGE returns 0, others may return handles > or TRUE, etc. So, if successful, SendMessage returns 0 when sending a WM_FONTCHANGE message to HWND_BROADCAST? What value is returned if SendMessage fails when sending WM_FONTCHANGE using HWND_BROADCAST?
6. Re: SendMessage Returns a Value?
- Posted by "Derek Parnell" <ddparnell at bigpond.com> Mar 23, 2004
- 444 views
----- Original Message ----- From: "C. K. Lester" <euphoric at cklester.com> To: <EUforum at topica.com> Subject: Re: SendMessage Returns a Value? > > > Evan Marshall wrote: > > > > > No. I see now that WM_FONTCHANGE returns 0, others may return handles > > or TRUE, etc. > > So, if successful, SendMessage returns 0 when sending a WM_FONTCHANGE > message to HWND_BROADCAST? What value is returned if SendMessage fails > when sending WM_FONTCHANGE using HWND_BROADCAST? > The return value from a WM_FONTCHANGE message should be ignored as it is not defined. Because this is sendiong a message to many windows running in other applications, the range of possible errors is too large to be represented by a single return value. So there is no return value. Either the other windows will be the message or not. Maybe you should us PostMessageA instead, as this always returns a true/false and does not wait for all windows to be notified before returning to your application.. -- Derek
7. Re: SendMessage Returns a Value?
- Posted by euphoric <euphoric at cklester.com> Mar 23, 2004
- 436 views
Derek Parnell wrote: >Because this is sendiong a message to many windows running in other >applications, the range of possible errors is too large to be represented by a >single return value. So there is no return value. Either the other windows will >be the message or not. Maybe you should us PostMessageA instead, as this always >returns a true/false and does not wait for all windows to be notified before >returning to your application. > > What does this statement mean: "Applications that need to communicate using HWND_BROADCAST should use the RegisterWindowMessage <http://msdn.microsoft.com/library/en-us/winui/WinUI/WindowsUserInterface/Windowing/MessagesandMessageQueues/MessagesandMessageQueuesReference/MessagesandMessageQueuesFunctions/RegisterWindowMessage.asp> function to obtain a unique message for inter-application communication." Does that apply to what I'm trying to do (which is just install a font and then HWND_BROADCAST a WM_FONTCHANGE message, for holy's sake). Bernie, using w32engine, how would I do the above? (I've already moved the font file into the fonts folder, so I just need to call AddFontResourceA and then broadcast the WM_FONTCHANGE message.) Thanks! Just for completeness sake, I'm pasting below how I do it now: if gdi32 = 0 then errMsg = "Couldn't open gdi32.dll!" else if AddFontResource != -1 then -- defined it earlier junk = allocate_string( "free000.ttf" ) if xSendMessage!= -1 then -- defined it earlier fonter = c_func( AddFontResource, { junk } ) -- call the function if fonter != 0 then junk = c_func(xSendMessage,{HWND_BROADCAST, WM_FONTCHANGE, 0, 0}) didAddFontResource = (1=1) else errMsg = "AddFontResource failed." end if else errMsg = "Could not access SendMessage." end if free(junk) else errMsg = "Could not access AddFontResource." end if end if
8. Re: SendMessage Returns a Value?
- Posted by "Derek Parnell" <ddparnell at bigpond.com> Mar 23, 2004
- 459 views
----- Original Message ----- From: "C. K. Lester" <euphoric at cklester.com> To: <EUforum at topica.com> Subject: Re: SendMessage Returns a Value? > > > Derek Parnell wrote: > > >Because this is sendiong a message to many windows running in other > >applications, the range of possible errors is too large to be represented by a > >single return value. So there is no return value. Either the other windows will > >be the message or not. Maybe you should us PostMessageA instead, as this always > >returns a true/false and does not wait for all windows to be notified before > >returning to your application. > > > > > What does this statement mean: "Applications that need to communicate > using HWND_BROADCAST should use the RegisterWindowMessage > > <http://msdn.microsoft.com/library/en-us/winui/WinUI/WindowsUserInterface/Windowing/MessagesandMessageQueues/MessagesandMessageQueuesReference/MessagesandMessageQueuesFunctions/RegisterWindowMessage.asp> > > function to obtain a unique message for inter-application communication." > > Does that apply to what I'm trying to do (which is just install a font > and then HWND_BROADCAST a WM_FONTCHANGE message, for holy's sake). No. The WM_FONTCHANGE message is a predefined one that all apps should know about. Its talking about 'normal' app-to-app communications. If one has two applications that need to send messages to each other, the RegisterWindowMessage is needed to create a unique message number in the system for those apps to pass. Not required for font changes. -- Derek
9. Re: SendMessage Returns a Value?
- Posted by "Bernard W. Ryan" <xotron at bluefrognet.net> Mar 23, 2004
- 432 views
CK: -- With w32engin.ew you would do this to add the font if not AddFontResourceA(sz("free000.ttf") then ShowLastError("AddFontResourceA Failed!") else ok = SendMessageA({HWND_BROADCAST,WM_FONTCHANGE, 0, 0}) end if szfree() -- free the sz string Bernie