• Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

VS C++ Express Registration

suityou01

Potty-trained
Thanks received
222
Man alive I'm having difficulty

All I want to do is create a simple screen grab POC using the GDI.

I have working C++ code, but the GUI is evading me.

I have created a GTK+ front end with a GTK Image widget. I have the DC of this image widget but when I try and stretchblt to it, it does not work.

I have googled around trying to find examples of stretch blting into GTK Image, and not found anything.

I posted in their forums over a day ago. No response. :mad

So I think, I know, I'll download VC++ 2008 express and use that for my POC. Install it, and it wants me to register it before I can use it. Ok great. I register it. Then I get a shiny email in my inbox thanking me for registering.

VC++2008E still wants a registration key :tantrum:

I just want to finish my POC, so can anyone either

Tell me where they found their reg key or

Point me in the direction of a code sample for doing a screen grab using GTK??

Thanks in advance
 
"You can obtain a new valid registration key by revisiting online registration. Just click the registration link in the “Register Product…” dialog and follow the instructions. You will be provided a new registration key." - MS VSE Registration FAQ.

The "Register Product..." dialog is accessed from the Help menu.

I haven't registered a copy in a while, but IIRC you cut & paste the key from the registration web site into VSE. For some reason they don't send it to you by email.

EDIT: oh, and I thought they allowed you to use it for thirty days before registering, although I suppose they may have changed that.
 
"You can obtain a new valid registration key by revisiting online registration. Just click the registration link in the “Register Product…” dialog and follow the instructions. You will be provided a new registration key." - MS VSE Registration FAQ.

The "Register Product..." dialog is accessed from the Help menu.

I haven't registered a copy in a while, but IIRC you cut & paste the key from the registration web site into VSE. For some reason they don't send it to you by email.

EDIT: oh, and I thought they allowed you to use it for thirty days before registering, although I suppose they may have changed that.

Worked like a charm. Which is more than I can say for my code. :rolleyes:

Code:
 public void CaptureScreenToPitureBox(int hDcPbx) //NB this is part of a class called Example
        {
            int hdcSrc = User32.GetWindowDC(User32.GetDesktopWindow()),
            hdcDest = GDI32.CreateCompatibleDC(hdcSrc),
            hBitmap = GDI32.CreateCompatibleBitmap(hdcSrc,
            GDI32.GetDeviceCaps(hdcSrc, 8), GDI32.GetDeviceCaps(hdcSrc, 10)); GDI32.SelectObject(hdcDest, hBitmap);
            GDI32.BitBlt(hdcDest, 0, 0, GDI32.GetDeviceCaps(hdcSrc, 8),
            GDI32.GetDeviceCaps(hdcSrc, 10), hdcSrc, 0, 0, 0x00CC0020);
            GDI32.StretchBlt(hDcPbx, 0, 0, 100, 100, hdcSrc, 0, 0, 1200, 800, GDI32.SRCCOPY);
        }

which is called thus
Code:
Example e = new Example();
Graphics pbG = this.pictureBox1.CreateGraphics();
e.CaptureScreenToPitureBox(pbG.GetHdc().ToInt32());
 
Worked like a charm. Which is more than I can say for my code. :rolleyes:

Code:
 public void CaptureScreenToPitureBox(int hDcPbx) //NB this is part of a class called Example
        {
            int hdcSrc = User32.GetWindowDC(User32.GetDesktopWindow()),
            hdcDest = GDI32.CreateCompatibleDC(hdcSrc),
            hBitmap = GDI32.CreateCompatibleBitmap(hdcSrc,
            GDI32.GetDeviceCaps(hdcSrc, 8), GDI32.GetDeviceCaps(hdcSrc, 10)); GDI32.SelectObject(hdcDest, hBitmap);
            GDI32.BitBlt(hdcDest, 0, 0, GDI32.GetDeviceCaps(hdcSrc, 8),
            GDI32.GetDeviceCaps(hdcSrc, 10), hdcSrc, 0, 0, 0x00CC0020);
            GDI32.StretchBlt(hDcPbx, 0, 0, 100, 100, hdcSrc, 0, 0, 1200, 800, GDI32.SRCCOPY);
        }

which is called thus
Code:
Example e = new Example();
Graphics pbG = this.pictureBox1.CreateGraphics();
e.CaptureScreenToPitureBox(pbG.GetHdc().ToInt32());

You've spelt "Picture" wrong in your method name, although you've also spelt it wrong in the method invocation. One of the pitfalls of IntelliSense :rolleyes:
 
You've spelt "Picture" wrong in your method name, although you've also spelt it wrong in the method invocation. One of the pitfalls of IntelliSense :rolleyes:

I noticed. Although this is not the root cause of the problem though.

You're not a consultant by any chance are you :laugh
 
Incidentally this is the second forum that cannot point me in the right direction with this code.

[apart from VectraMan]
edit : [and NF]

HTH :moon:
 
Last edited: 18:43
Incidentally this is the second forum that cannot point me in the right direction with this code.

You haven't even said what doesn't work, so it's unlikely anybody will be able to help. Does it fail to compile? Does it compile but throw a runtime exception? Does it compile and run without crashing but not do what you expect it to?

VS has a very good debugger, and it's only a few lines to step through to identify the precise point of failure, at which point looking at the MSDN docs for the relevant API call will probably point you in the right direction. Search on Raymond's blog for the relevant function's name as well, as he often mentions various gotchas and he's written loads about GDI in the past.
 

Advertisers

Back
Top