🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Creating a Window from a Console App... How to?!?

#9852
From: Ed Mulroy [TeamB]
Date: Fri, 11 Jun 2004 12:24
54 lines
2714 bytes
I cannot with certainty tell you why it does that, but there are three
things in that code which I think must be changed.


The program's instance is not given in this call

> hWnd=CreateWindowEx(WS_EX_OVERLAPPEDWINDOW,
>     szAppName, "Test Window",
>     WS_OVERLAPPEDWINDOW | WS_VISIBLE,
>     CW_USEDEFAULT, CW_USEDEFAULT, 500, 500,
>     NULL, NULL, NULL, NULL );

Change the call to this

  hWnd=CreateWindowEx(WS_EX_OVERLAPPEDWINDOW,
      szAppName, "Test Window",
      WS_OVERLAPPEDWINDOW | WS_VISIBLE,
      CW_USEDEFAULT, CW_USEDEFAULT, 500, 500,
      NULL, NULL, _hInstance, NULL );

_hInstance contains the instance handle for your program and is a
variable created by the startup code.  Add this line following the
includes to declare it for the program:

  extern HINSTANCE _hInstance;


You have a case for WM_DESTROY but no case for WM_CLOSE.  Add a
WM_CLOSE case and either let it fall through to the WM_DESTROY case or
have it call PostMessage to post a WM_DESTROY to the window.


The code uses CreateThread.  It should use one of _beginthread or
_beginthreadNT and not CreateThread so that TLS is properly
initialized.  Read the help on _beginthread for more details of why it
should be used instead of CreateThread.

.  Ed

> Filippo wrote in message
> news:40c98aec$1@newsgroups.borland.com...
> Hello,
>     I try to create a window from a Console App (so with main() and
without
> the 'WinMain...').
>     To do this I created a new thread inside the main console app
that
> register the window and show it... seems to work but...
>     I have some problem when I try to resize the window... all the
desktop
> become white! without refreshing it.
>     How can I create a window from a console app not in this 'dirty'
way?
> ...
Technical Details
Message-ID: <40c9a47f@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <40c98aec$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,3be54e0f405e81ba
X-Google-Attributes: gid10cc67,public
From: "Ed Mulroy [TeamB]" <dont_email_me@bitbuc.ket>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <40c98aec$1@newsgroups.borland.com>
Subject: Re: Creating a Window from a Console App... How to?!?
Date: Fri, 11 Jun 2004 08:24:19 -0400
Lines: 56
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1409
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409
NNTP-Posting-Host: 12.161.27.74
Message-ID: <40c9a47f@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1086956671 12.161.27.74 (11 Jun 2004 05:24:31 -0700)
X-Authenticated-User: edmulroy
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail