🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #5729

Re: Overlay on camera display window

#5729
From: Hans-Jochen Trost
Date: Mon, 25 Jul 2005 16:01
124 lines
6257 bytes
Remy,

thanks for the advice.

>> I am thinking about a separate window, appropriately sized, with a
>> transparent background and the cross hair drawn on it, so sit on top
>> of the image display window (which is also the main program window).
>
>Why not just maintain a separate bitmap in memory, copy your images to it
>when needed, draw the cross directly onto it whenever you change it, and
>then have the main window simply render the current bitmap when needed?
>This is known as "double-buffering".

I'm dealing with slow computers (industrials, Pentium 166 MHz w/ MMX)
and am trying to run the frame grabber (which supplies the image
stream as bitmaps already)  at full speed, i.e., 30 fps.  I'll try
this.

>> 2.  If it is, how do I tell it to not display a title bar?
>
>Simply don't give the window the WS_CAPTION style.

That's what I thought, but it refuses to do as told.  Here is how the
main and the overlay windows are defined right now (no transparency
yet):

    // Register window class
    wndclass.style = CS_HREDRAW | CS_VREDRAW;
    wndclass.lpfnWndProc = WndProc;
    wndclass.cbClsExtra = 0;
    wndclass.cbWndExtra = 0;
    wndclass.hInstance = hInst;
    wndclass.hIcon = LoadIcon (hInst, "ICONX11");
    wndclass.hCursor = LoadCursor (NULL, IDC_ARROW);
    wndclass.hbrBackground = GetStockObject (WHITE_BRUSH);
    wndclass.lpszMenuName = "Sample2";
    wndclass.lpszClassName = szAppName;
    RegisterClass (&wndclass);

    // Create program window
        xwidth  = XACT_NTSC + GetSystemMetrics(SM_CXBORDER) * 2 ;
        yheight = YACT_NTSC + GetSystemMetrics(SM_CYCAPTION) +
                                        GetSystemMetrics(SM_CYMENU) ;
    hwndMain = CreateWindow(szAppName, szAppName,
                                       WS_OVERLAPPEDWINDOW ^
                                          WS_MAXIMIZEBOX ^WS_SIZEBOX,
                                       CW_USEDEFAULT, CW_USEDEFAULT,
                                       xwidth,
                                       yheight +
                                    GetSystemMetrics(SM_CYBORDER) * 2,
                                       NULL, NULL, hInst, NULL);

    ShowWindow (hwndMain, SW_SHOWNORMAL);
    SetWindowPos (hwndMain, HWND_TOP, 0, 0, xwidth, yheight,
                                    SWP_NOMOVE);

    hMenuAcq = GetSubMenu(GetMenu(hwndMain), 1); // Acquisition menu

    // Register window class
    crossclass.style = CS_HREDRAW | CS_VREDRAW;
    crossclass.lpfnWndProc = WndProc;
    crossclass.cbClsExtra = 0;
    crossclass.cbWndExtra = 0;
    crossclass.hInstance = hInst;
    crossclass.hIcon = LoadIcon (hInst, "ICONX11");
    crossclass.hCursor = LoadCursor (NULL, IDC_ARROW);
    crossclass.hbrBackground = GetStockObject (WHITE_BRUSH);
    crossclass.lpszMenuName = NULL ;
    crossclass.lpszClassName = szCrosshair;
    RegisterClass (&crossclass);
        // Create overlay window for cross hair.
        GetWindowRect(hwndMain, &mainRect) ;
        xwidth = XACT_NTSC + 2 ;
        yheight = YACT_NTSC + 2 ;
        hwndCross = CreateWindow(szCrosshair, NULL,
                               WS_BORDER,
                               mainRect.left +
                                    GetSystemMetrics(SM_CXBORDER) - 1,
                               mainRect.top +
                                    GetSystemMetrics(SM_CYBORDER) +
                                    GetSystemMetrics(SM_CYCAPTION) +
                                    GetSystemMetrics(SM_CYMENU),
                               xwidth, yheight,
                               hwndMain, NULL, hInst, NULL) ;
        SetMenu(hwndCross, NULL) ;
        ShowWindow(hwndCross, SW_SHOWNORMAL) ;
        SetWindowPos(hwndCross, HWND_TOP, 0, 0, xwidth, yheight,
                                        SWP_NOMOVE) ;

It does not matter if I keep this a separate window class, or reuse
the main window class, and what I put in for the style - WS_BORDER,
WS_DLGFRAME, WS_OVERLAPPED (which is 0x0L) all give the same result,
i.e., there is a title bar.  I also can set the icon handle to NULL
and there still is a title bar.  The paint process for the overlay
window is all of

     BeginPaint(&ps); EndPaint(&ps);

If you now think this guy has never done plain API windows you are
right - I have for a long time gone with OWL, and have for a bunch of
more recent apps usually used VCL.  My problem here is that I have the
plain windows app which does everyhing I want except that the cross
hair gets drawn on every displayed image and I want to shave off that
time (and get id of the unstable cross display, I got customers to
please ...).

>> 3.  How do I tell it to have a transparent background?
>
>Give the window the WS_EX_TRANSPARENT style, and also intercept the
>WM_ERASEBKGND message to not actually draw any background.

Now that's easy ...


Thanks again,

Jochen

hjtrost at microfab dot com


Nil nimium studeo, Caesar, tibi velle placere,
nec scire ut an sis albus an ater homo.
                                          Catullus
Technical Details
Message-ID: <p21ae11d4tkah2bk701b45u5ap8dn0ud4k@4ax.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!newsread.com!news-xfer.newsread.com!news.glorb.com!news.moat.net!news-out.newsfeeds.com!propagator3-LAX.newsfeeds.com!news-in.newsfeeds.com!news-in.superfeed.net!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <rh03e1pm0o0i7t274u6djcbcdne8m01tna@4ax.com> <42e1926c$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,5bf0f3f06cc6974f
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: Hans-Jochen Trost <dont-email@but.post-re.ply>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: Overlay on camera display window
Date: Mon, 25 Jul 2005 11:01:50 -0500
Organization: MicroFab Technologies, Inc.
Reply-To: dont-email@but.post-re.ply
Message-ID: <p21ae11d4tkah2bk701b45u5ap8dn0ud4k@4ax.com>
References: <rh03e1pm0o0i7t274u6djcbcdne8m01tna@4ax.com> <42e1926c$1@newsgroups.borland.com>
X-Newsreader: Forte Free Agent 1.93/32.576 English (American)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 24.1.60.14
X-Trace: newsgroups.borland.com 1122307307 24.1.60.14 (25 Jul 2005 09:01:47 -0700)
Lines: 124
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!newsread.com!news-xfer.newsread.com!news.glorb.com!news.moat.net!news-out.newsfeeds.com!propagator3-LAX.newsfeeds.com!news-in.newsfeeds.com!news-in.superfeed.net!caladan.landsraad.net!newsgroups.borland.com!not-for-mail