Hello!
I've been professionally working on java projects for several years, but
have done extremely little C/C++ coding and just a few little things in
VB.Net.
Right now I'm trying to write a Windows Service in VC++ .Net thats
supposed to use a 3rd party SDK do receive Image data and send it out
through a webservice.
In the 3rd party sdk there is a function that requires a HWND to be
passed to it. It then uses the component behind that handle to paint the
images straight to it (Actually what i think it does is getting the
position and dimension of the component and drawing via directX
overlay). However, it also supports registering a custom callback
methode where the actual raw picture data is passed to.
By writing a custom callback methode i can receive all the data I need,
but only if i provide a valid HWND in the first place (NULL and 0 both
result in an exception stating the Windowhandle was invalid).
Since I need the whole thing to run as a windows service I dont have a
handle to a real Window or Form component, so Im looking for a way to
create a dummy window component, that is going to "look and feel" like a
real component to the 3rd party method.
Hope anyone can provide some information on how to deal with this problem.
Kind regards,
Kolja 11 4638
"Kolja Märtens" <ha*@haznet.dew rote in message
news:g6******** **@online.de...
Hello!
I've been professionally working on java projects for several years, but
have done extremely little C/C++ coding and just a few little things in
VB.Net.
Right now I'm trying to write a Windows Service in VC++ .Net thats
supposed to use a 3rd party SDK do receive Image data and send it out
through a webservice.
In the 3rd party sdk there is a function that requires a HWND to be passed
to it. It then uses the component behind that handle to paint the images
straight to it (Actually what i think it does is getting the position and
dimension of the component and drawing via directX overlay). However, it
also supports registering a custom callback methode where the actual raw
picture data is passed to.
By writing a custom callback methode i can receive all the data I need,
but only if i provide a valid HWND in the first place (NULL and 0 both
result in an exception stating the Windowhandle was invalid).
Since I need the whole thing to run as a windows service I dont have a
handle to a real Window or Form component, so Im looking for a way to
create a dummy window component, that is going to "look and feel" like a
real component to the 3rd party method.
You should have no problem creating a hidden window in your service (not
that it would show if it wasn't hidden anyway).
The RegisterClass and CreateWindow APIs should work fine. Just create the
window without the WS_VISIBLE style.
You'll maybe want to do this on a thread with a message loop :)
Mark
--
Mark Salsbery
Microsoft MVP - Visual C++
>
Hope anyone can provide some information on how to deal with this problem.
Kind regards,
Kolja
Mark Salsbery [MVP] wrote:
>
You should have no problem creating a hidden window in your service (not
that it would show if it wasn't hidden anyway).
The RegisterClass and CreateWindow APIs should work fine. Just create
the window without the WS_VISIBLE style.
You'll maybe want to do this on a thread with a message loop :)
Thanx for your reply, Im not sure if I understand exactly what you mean.
Allready before I read your post I tried to open a window by manually
calling CreateWindow (this time form a .Net console application for
testing).
Heres what I tried (after googeling for hours):
HWND hWnd = CreateWindow("S TATIC", "", 0, 0, 0, 0, 0, NULL, NULL, NULL,
NULL);
It compiles, but hWnd is not propperly initialized, Ill try research on
RegisterClass as you mentioned.
"Kolja Märtens" <ha*@haznet.dew rote in message
news:g6******** **@online.de...
Mark Salsbery [MVP] wrote:
>> You should have no problem creating a hidden window in your service (not that it would show if it wasn't hidden anyway).
The RegisterClass and CreateWindow APIs should work fine. Just create the window without the WS_VISIBLE style. You'll maybe want to do this on a thread with a message loop :)
Thanx for your reply, Im not sure if I understand exactly what you mean.
Allready before I read your post I tried to open a window by manually
calling CreateWindow (this time form a .Net console application for
testing).
Heres what I tried (after googeling for hours):
HWND hWnd = CreateWindow("S TATIC", "", 0, 0, 0, 0, 0, NULL, NULL, NULL,
NULL);
It compiles, but hWnd is not propperly initialized, Ill try research on
RegisterClass as you mentioned.
See
Using Window Classes http://msdn.microsoft.com/en-us/libr...75(VS.85).aspx
Mark
--
Mark Salsbery
Microsoft MVP - Visual C++
Kolja Märtens wrote:
Mark Salsbery [MVP] wrote:
>> You should have no problem creating a hidden window in your service (not that it would show if it wasn't hidden anyway).
The RegisterClass and CreateWindow APIs should work fine. Just create the window without the WS_VISIBLE style. You'll maybe want to do this on a thread with a message loop :)
Thanx for your reply, Im not sure if I understand exactly what you
mean. Allready before I read your post I tried to open a window by
manually calling CreateWindow (this time form a .Net console
application for testing).
If you are using .NET, use the NativeWindow class, read the Handle property
to get the HWND, override WndProc, etc.
>
Heres what I tried (after googeling for hours):
HWND hWnd = CreateWindow("S TATIC", "", 0, 0, 0, 0, 0, NULL, NULL,
NULL, NULL);
It compiles, but hWnd is not propperly initialized, Ill try research
on RegisterClass as you mentioned.
Ben Voigt [C++ MVP] wrote:
If you are using .NET, use the NativeWindow class, read the Handle property
to get the HWND, override WndProc, etc.
That seemed like an easy approach so I tried.
NativeWindow * w = new NativeWindow();
CreateParams * params = new CreateParams();
params->X=100;
params->Y=100;
params->Height=100;
params->Width=100;
w->CreateHandle(p arams);
The Handle Parameter of the Window becomes !=0 wich seems good.
But when I try to get the HWND by
HWND hWnd = (HWND)w->get_Handle().T oPointer();
the HWND is still uninitialized.
I was really hoping to find a quick solution that works without the need
to understand a whole lot about windows programming so I can get back to
the Java Part of the Solution (The server side of the webservice).
Unfortunately the more I tried the less I think it will be possible
without digging deeper and at least starting to understand how this works...
Kolja Märtens schrieb:
The Handle Parameter of the Window becomes !=0 wich seems good.
But when I try to get the HWND by
HWND hWnd = (HWND)w->get_Handle().T oPointer();
the HWND is still uninitialized.
I wrote a class that inherits from NativeWindow and with that I managed
to get a working HWND now. Not sure what went wrong earlier, cause it
seems like it should have worked before.
Unfortunately the Callback method mentioned earlier is never invoked.
It seems a lot like the 3rd party Thread that does the painting was
checking if the window at the provided HWND is visible before it even
starts doing something.
In the .net forms application i can simulate this behavior by calling
Hide() on the Window.
Is there a way to make the 3rd party thread think the window was visible
and all good?
I suppose I should overwrite the function that is used for detecting if
the window is visible and sinply return true, but i have no clue what
funtion that is.
I wish i had the eclipse IDE that Im familiar with and could just click
on "overwrite/implement Methods..."
Kolja Märtens schrieb:
Is there a way to make the 3rd party thread think the window was visible
and all good?
Ive done some more testing and found that the callback is invoked fine
when i allow the Service to interact with the desktop and call
ShowWindow on the Windowclass I created.
I suppose I should overwrite the function that is used for detecting if
the window is visible and sinply return true, but i have no clue what
funtion that is.
still looking for that.
Kolja Märtens wrote:
Kolja Märtens schrieb:
>Is there a way to make the 3rd party thread think the window was visible and all good?
Ive done some more testing and found that the callback is invoked fine
when i allow the Service to interact with the desktop and call
ShowWindow on the Windowclass I created.
ShowWindow should have worked fine and set the WS_VISIBLE flag even when the
application runs on a service desktop.
However, if the callback is triggered by WM_PAINT it will only happen when
the window really is on the screen. However, you can InvalidateWindo w and
SendMessage WM_PAINT to the window yourself.
>
>I suppose I should overwrite the function that is used for detecting if the window is visible and sinply return true, but i have no clue what funtion that is.
still looking for that.
Bad idea. The function is provided by Microsoft inside USER32.dll.
Ben Voigt [C++ MVP] schrieb:
>
ShowWindow should have worked fine and set the WS_VISIBLE flag even when the
application runs on a service desktop.
What do you mean by "service desktop"?
The Callback is indeed invoked even when the user is logged of as long
as the Service has the right to interact with the desktop.
Big drawback is, once a user logs in, the Window is displayed and thats
something I definetly dont want.
However, if the callback is triggered by WM_PAINT it will only happen when
the window really is on the screen. However, you can InvalidateWindo w and
SendMessage WM_PAINT to the window yourself.
I tracked all window messages in my dummy window class and passed them
on to the NativeWindow WndProc. Seems like the window was only used
during initialization because when the process starts drawing the
Pictures (in an overlay i suppose) there are no more window messages
coming in.
Heres what WndProc is getting:
36 WM_GETMINMAXINF O
129 WM_NCCREATE
131 WM_NCCALCSIZE
1 WM_CREATE
24 WM_SHOWWINDOW
70 WM_WINDOWPOSCHA NGING
70 WM_WINDOWPOSCHA NGING
28 WM_ACTIVATEAPP
13 WM_GETTEXT
134 WM_NCACTIVATE
642 WM_IME_NOTIFY
641 WM_IME_SETCONTE XT
7 WM_SETFOCUS
6 WM_ACTIVATE
13 WM_GETTEXT
133 WM_NCPAINT
20 WM_ERASEBKGND
71 WM_WINDOWPOSCHA NGED
5 WM_SIZE
3 WM_MOVE
I just realized that there is indeed one WM_PAINT.
From what I know about video overlay I think the Background of the
Window is changed to magenta to mark the aerea to overlay.
Ill have to read about what InvalidateWindo w does...
>>I suppose I should overwrite the function that is used for detecting if the window is visible and sinply return true, but i have no clue what funtion that is.
still looking for that.
Bad idea. The function is provided by Microsoft inside USER32.dll.
I was hoping for something like "bool isVisible()" in the Windowclass...
I know by now this is not the way things work around here :) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Andrew Moore |
last post by:
Hi All,
I have a managed C++ class that makes calls into the Win32 API. I
specifically am trying to take a Handle from a .NET form and convert it to a
HWND to pass to a Win32 functions. The code works properly but I get the
following compiler warning:
warning C4312: 'reinterpret_cast' : conversion from 'int' to 'HWND' of
greater size.
|
by: Zeya |
last post by:
I have this code, which uses WMI to operate on Windows service from C#
code.
When Service.InvokeMethod is called, the method throws an exception:
System.Management Operation is not valid due to the current state of
the object. at System.Management.ManagementObject.InvokeMethod(String
methodName, Object args)
|
by: Bonj |
last post by:
Is PostQuitMessage(?) different to PostMessage(hWnd, WM_QUIT, ... ) ?
I've got a window in a DLL (the same one experiencing the issue below,
"return value of WM_QUIT") in which PostMessage(hWnd, WM_QUIT, ... ) works,
but PostQuitMessage doesn't.
I would assume this to be the case as PostQuitMessage can't possibly know
the hWnd I'm wanting it to operate on. So why does the docs advise you to use
that?
|
by: MrBewsher |
last post by:
Hi,
I'm using VB.Net and writing an NT service that runs in the system
account in the background with no interaction with the desktop.
I'm running it on XP Pro.
I'd like to get the URL of any Internet Explorer process a logged in
user is running.
I can get a list of process IDs and from that use
|
by: --== Alain ==-- |
last post by:
Hi,
When i debugged my code (see below) from my overrider WndProc method, i
discovered that update has alway left, right, botton and top set to 0.
therefore i wonder if my hwnd point to the right value.
how can i know that ?
thx.
| |
by: =?Utf-8?B?Sm9hY2hpbQ==?= |
last post by:
How can I pass a C++ HWND to and from C# and Managed C++?
|
by: c2 |
last post by:
hi,
i face a problem when click the icon , my login will prompt this
message
String was not recognized as a valid Boolean
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.FormatException: String was not recognized as a valid Boolean.
|
by: BarryM |
last post by:
I was told that this piece coding to find the es_password state in c# would work but an error message saying hWnd does not exist in the current context
internal static class UnsafeNativeMethods
{
public const int GWL_STYLE = -16;
public const int ES_PASSWORD = 0x20;
public static extern int GetClassName(HandleRef hWnd, System.Text.StringBuilder lpClassName, int nMaxCount);
...
|
by: =?Utf-8?B?YW5kcmV3?= |
last post by:
I have a web application demo page and a web service.
On my machine everything works great.
In our test environment the web service is working fine... when I point the
demo page on my machine to the test environment web service I get results as
expected.
The demo page in the test environment which is pointed at the web service in
the test environment doesn't work at all... instead I end up with this
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |