Hosting windowless control

I have a windowless control - it has to be windowless because it's not
rectangular.  I have used it many times in VB applications without problem.
Recently I tried to include it in an MFC dialog box and it doesn't work.  It
appears to be being drawn with a control window.

What happens is that MFC blanks the rectangular area of the control site to
white before invoking the control's draw function.

Debugging through the control (which is ATL), I have discovered that when
the host is a VB application it is, indeed, windowless (control's bWndLess
member = TRUE) but when hosted from MFC bWndLess is FALSE.

Any suggestions?

Keith


0
3/31/2005 8:26:17 AM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
545 Views

Similar Articles

[PageSpeed] 19

Interesting question.

I'm not 100% sure what you mean by "windowless control". Do you mean
borderless? BTW you can implement non-rectangular windowed controls. See Joe
Newcomers essay on this. Far better than any explanation I can give.

>I have discovered that when
> the host is a VB application it is, indeed, windowless (control's bWndLess
> member = TRUE) but when hosted from MFC bWndLess is FALSE.

But this bWndLess variable is just a variable invented by the control
writer. I mean it has no meaning to the OS. Can't you just set this variable
in code?

> What happens is that MFC blanks the rectangular area of the control site
to
> white before invoking the control's draw function.

I think this is called erasing the background, which I believe can be either
done or not done based on programmer preference.

"Keith Sheppard" <keith.sheppard@tesco.net> wrote in message
news:eB74YtcNFHA.2736@TK2MSFTNGP09.phx.gbl...
> I have a windowless control - it has to be windowless because it's not
> rectangular.  I have used it many times in VB applications without
problem.
> Recently I tried to include it in an MFC dialog box and it doesn't work.
It
> appears to be being drawn with a control window.
>
> What happens is that MFC blanks the rectangular area of the control site
to
> white before invoking the control's draw function.
>
> Debugging through the control (which is ATL), I have discovered that when
> the host is a VB application it is, indeed, windowless (control's bWndLess
> member = TRUE) but when hosted from MFC bWndLess is FALSE.
>
> Any suggestions?
>
> Keith
>
>


0
KMA (44)
3/31/2005 12:19:37 PM
>>I'm not 100% sure what you mean by "windowless control". Do you mean
>>borderless? BTW you can implement non-rectangular windowed controls. See
Joe
>>Newcomers essay on this. Far better than any explanation I can give.
In my understanding, a windowless control is one which does not have its own
child window.  Instead its OnDraw() method draws directly into the client
area of the host window.  From my point of view, all I want to do is to
implement a non rectangular control.  The problem is that the container
(Visual C++ dialog box) keeps blanking the control site to white before my
control's OnDraw() method gets called.  Where do I find Joe Newcomer's
essay?

>>>I have discovered that when
>>> the host is a VB application it is, indeed, windowless (control's
bWndLess
>>> member = TRUE) but when hosted from MFC bWndLess is FALSE.
>>
>>But this bWndLess variable is just a variable invented by the control
>>writer. I mean it has no meaning to the OS. Can't you just set this
variable
>>in code?
The m_bWndLess member is invented by Visual C++ ATL control wizard.  It is a
standard member of class CComControl and is documented in MSDN and I quote:

<QUOTE>
Remarks

Flag indicating the control is windowless.

The data member m_spInPlaceSite points to
anIOleInPlaceSite,IOleInPlaceSiteEx, orIOleInPlaceSiteWindowless interface,
depending on the value of the m_bWndless and m_bInPlaceSiteEx flags. (The
data member m_bNegotiatedWnd must be TRUE for the m_spInPlaceSite pointer to
be valid.)

If m_bWndless is TRUE, m_spInPlaceSite is an IOleInPlaceSiteWindowless
interface pointer. See m_spInPlaceSite for a table showing the complete
relationship between these data members.
<<END QUOTE>

Most of this is gobbledy-gook to me but I get the impression that even I
could set it in code, I doubt that it would do much good.  I think its
purpose is to convey information to me rather than actually _do_ anything.

>>> What happens is that MFC blanks the rectangular area of the control site
>>>to white before invoking the control's draw function.
>>
>>I think this is called erasing the background, which I believe can be
either
>>done or not done based on programmer preference.
I'm not sure where, as the programmer, I get to vote.  I know that if I
explicitly call InvalidateRect() I can specify whether to blank first (and,
incidentally, I have never yet written a program where I _do_ choose to
blank the area, which makes me wonder why that's the default action; but
that's another matter).  However, this is on an implicit redraw.  Eg. after
covering then uncovering the window.

Regards
Keith






0
4/1/2005 9:11:49 AM
Reply:

Similar Artilces:

Suggest technique for a totals control based on subform
I have a SalesDetails subform on which user selects various services to be installed. The choices are looked up from a tblSalesCodes. We have an install fee which is $19.95 for first services and 9.95 for each subsequent service. The service choices includes both individual and bundled services. What I mean by this is that user could select a choice that has 1 service, and therefore the install fee is $19.95. Or they could select a choice that has 2 service, so install fee is $29.90. Or they could select 2 choices, each with one service, so it's $29.90. On tblSalesCodes, I have e...

Virtual list control #2
Needed to use it. Very simple and straighforward, and I am mostly happy with it, with the exception that scrolling is slower than I had hoped. I did expect scrolling to be slower, but not that much slower. Population and scrolling are fantastic compared with standard list of course. Actually, I can live with the vertical scrolling. I was disappointed to run sample apps, and see how bad horizontal scrolling was. Looking at the messages, the LVN_GETDISPINFO message is sent for every single cell in the visible rows, whether they are in visible columns or not. Well, OK, I can live with that, *ex...

Need help on usng windows control library component in mfc application
Hi , I have Created a Windows control library component to draw a bitmap image using VC.Net 2003 , I can able to use the component in wndows form application. I dont know how to use the same in VC.Net MFC application can any one help me in this. With regards, Sathish. ...

Microsoft Web Browser Control background color?
Greetings, I am using the CHtmlView which I believe is using the Microsoft Web Browser Control. I can't figure out how to change the background color while in an html view so that if a web page isn't assigned to the control it won't default to white. Instead use a different color is there way to change this? Thanks in advance for any suggestions! I dont see how you can do this w/o the IWebBrowser2 contained in the CHTMLView knowing about it. You can do it by style sheets, scripts etc, all the HTML based technology behind it; but not thru Win32 or MFC directly. -- Ajay Kal...

Add Controls at Runtime with Events
I need to add a series of controls at runtime in Excel that I can interact with via events. How do I do this? Specifically, my program automatically queries a database every five minutes to update it's information. The information is constantly changing. For each record in the database, the program creates a row of info on an Excel worksheet. I want to be able to create a command button and label for each record on the worksheet. How would I accomplish this? Thanks in advance! Try something like the following code Dim OLEObj As OLEObject Dim Rng As Range Dim WS As Worksheet Dim C...

CRM 3.0 SPLA
Hi, Our company is deploying the “Hosted CRM 3.0 Solution for Hosted Messaging and Collaboration version 3.5”. Whenever we performed the required manual setup, we have encountered the following error message from CRM ‘setupserver.exe’ Application: “Unknow command line argument: /preinstall” Without this parameter, all the installation process works fine but it fails in the following step: “Procedure CRM.27: To verify the presence of the Hosted CRM Stage1 MinisetupPending registry subkey”. It seems that this problem is related to our media set. We are using the volume licensing “Micros...

Form and SubForm-Control resizing to fit Form contained in SubForm-Control
Have compiled code. IE, variables not declared are declared in the module level. Form has an option group and a subform control. When an option is clicked its "respective" (whose name is contained inthe clicked options tag) form is loaded into the subform via the code below. That bit works fine. The problem is that the form loaded into the subform control are of different sizes, so I need to resize the main form and subform control such that the form that is loaded into the subform control is perfectly visible and nicely sized. I'm using the following code. The height works fin...

ActiveX control functionality
I need to apply some tcp communication capability to an ActiveX control and I don't know if it will work. specifically, it should implement tcp server that listens on some port and do something when client connects. Is that possible? Thanks Gino In addition to my previous question, Suppose the Activex control works fine in my Html page (nomatter what its actual functionality), what happens to its functionality when the user closes the browser, or just jumps to another page? Does it stay "alive" by its own? Who is responsible to close the Activex control and is it posible...

Using InStr on form control
Hi, I have this bit of code: Dim myText As Variant, i As Long If Not IsNull(Me.mktAreaCombo) Or Me.mktAreaCombo = "" Then If InStr(Me.mktAreaCombo, "...") > 0 Then MsgBox "... Detected!" myText = Split(Me.mktAreaCombo, "...") For i = LBound(myText) To UBound(myText) MsgBox myText(i) Next i Else strWhere = strWhere & "([mktArea] = " & Me.Controls("mktAreaCombo") & ") AND " MsgBox "No ..." ...

Dynamic tab controls
Hi, I hav created my dialog box dynamically and added the tab controls in the same way. Now the problem is where to handle the tab controls . I tried it in OnChildNotify(),but its not working. U can send me reply on <manish_4u5@yahoo.co.in> regards manish ...

$19.99 Unlimited Space !
$19.99 Unlimited Space ! Managed Hosted Microsoft Exchange Server & 30 day FREE trial ! http://www.DataSyncPros.com Outlook was ment to be on Exchange - Experience the power ! Access your email, calendar, contacts & task list from anywhere! Provide shared access to co-workers in real-time...24/7 DataSyncPros Hosted Exchange Solution allows your business to communicate and collaborate more efficiently and effectively. Using Microsoft=AE Outlook 2003 software and features, DataSyncPros Hosted Exchange offers real-time access to your Outlook profile (email, calendar, task list and a...

Exchange 2003 domain controller
I know you can put Exchange 2003 on a domain controller or not. Anyone know the pros and cons of why you would or would not? Just a few reasons not to: Performance Impact Complicates DR. Exchange Admins will have logon locally rights to the DC. Longer shutdowns if you do not stop the Exch services first. Security issues in general. THere are other reasons, but those are off the top of my head. On 6 May 2004 13:40:19 -0700, alunk@sunwest-peo.com (Andy Lunk) wrote: >I know you can put Exchange 2003 on a domain controller or not. >Anyone know the pros and cons of why you would or...

How do I disable the ActiveX Control prompt?
I have a ActiveX Control in an Excel spreadsheet workbook. And this workbook will be called and run automatically twice every day. But there is this prompt which say that ActiveX controls might be unsafe and the program will be hanging there awaiting for the user to click Yes or No. How can I disable this prompt? Thanks! Keith! ...

CanShrink Works On Some Controls But Not Others
I have a receipt report (for a small clothing retail) with several items arranged vertically, including "Subtotal", "Freight", "Monogram" (fee), and total. I've set the CanShrink propert of these controls, with the result that the "Freight" control will shrink beautifully but the Monogram control never shrinks. These two controls have identical properties except for their positions and are both tied to Currency fields in the underlying query. Here's a screen shot of the report with the properties of the Monogram control displayed. ...

Specify additional host in Internet Mail Service Connections
Can somebody tell me the proper way to specify an additional host to accept mail messages from my Internet Mail Service? In the Internet Mail Service Properties under the 'Connections' Tab I have an IP address specified in the 'Message Delivery' portion of the screen. The option to 'Forward all messages to host:' is selected. If I were to want to forward to another host (for load balancing purposes) can I simply enter a comma and a second IP address or is there more to it? If so what else do I have to do if I want to forward my mail to two different SMTP ...

Position of Control in Dialog Box ?
Hi guys, How do I get the top-left position of a control in a dialog box ? I tried GetWindowRect() but it's in screen coordinates. I want to create a static frame then go like this: (pseudo code) rect = client rect of static control fill rect If I use GetClientRect it's at 0,0, so I need the top-left position so I can offset the rect. Thanks. You can use ScreenToClient to convert it to client coordinates. -- Ajay Kalra [MVP - VC++] ajaykalra@yahoo.com "Robert A." <invalid@invalid.org> wrote in message news:mwN_b.75089$ac.17794820@news4.srv.hcvlny.cv.net... | ...

Minimize message for controls
It is easy to respond to minimize messages in a dialog and from there, send it to child controls if necessary. I wonder if it is possible for a child control to be aware of a minimize message directly, that is, WITHOUT sending it explicitly upon interception in its parent dialog. Thanks people. On 19 Feb 2007 06:37:21 -0800, "Alexander" <the44secs@yahoo.com> wrote: >It is easy to respond to minimize messages in a dialog and from there, >send it to child controls if necessary. I wonder if it is possible for >a child control to be aware of a minimize message directly...

URGENT HELP NEEDED!!!!: overlapping controls in Dialog
Hello group, I am not too advanced on MFC and it is about 3:00 in the morning, so sorry if the question turns out to be a silly one. My aim is to construct something like Excel editor window on a Dialog box. Detailed: I have a custom grid control and an edit box placed on a dialog. All input in the grid is reflected in the editbox. When the input is larger than the edit box widths its height increases and the input goes to the next line. The problem which I am facing now is the following. When a cell is clicked where the text is quite long - the edit box is enhanced (in order to show all the...

Can't see calculated control
I have a calculated control on a report called txttotalID with a record source which is =YTDValue("txtMonth","CountofID","qrypurpose",[txtmonth]) The YTDValue refers to a Module taht calculates YTD figures The rpeorts record source is qrypurpose and the query has the fileds txtmonth and CountofID and that works fine and gives me a value.. I have another calculated control called TotalID where the record source is =Sum([txttotalID]), the txttotalID being my first calculated control. However, when I run the report I get a prompt asking for the value of tx...

Remote control volume indicator
How do I restore the green volume indicator bar graphic to my desktop? We need a little more info to offer any help. What version of Media Center? Do you mean that when you are in Media Center (watching a TV show. for example) and you press the Vol +/-, you don't see the indicator at the top right of the screen? .... or are you talking about some other volume indicator that is specific to your model PC? -- James Wolf [MS-MVP] Orlando, FL "swordfisch" <swordfisch@discussions.microsoft.com> wrote in message news:4A114587-B699-4520-BD0F-0F11246F79B7@...

Tab controls/ Hiding Tabs
I am looking for some coding assistance. I have a tab control called "Master Tab" with 3 tabs on it called "Type" "CIP" and "Vacuum". When I load the tab control form I want "CIP" and "Vacuum" to be hidden - only "Type" should be showing. Then when I want to go to the "CIP" tab, I would like to create an event that hides the "Type" form and makes the "CIP" form visible. Any ideas? Thanks, Zag -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/Forums.aspx/access-forms...

Breaking the 30,000 character limit in a CString/CEdit control
I have a multiline CEdit control in a modal dialog. I find that even though no Maximum Characters is set and there is no call to DDV_MaxChars() in DoDataExchange(), there is a limit of 30000 characters that can be pasted or entered. My problem is fixed on Windows 2K if I add a higher Maximum Characters. I'd like a megabyte of text or so, but can live with 100K. Will this work on Win95/Me/98/XP? Or is there a problem with more than 32K or 64K characters in a CString there. MFC is statically linked in the app. Thanks for all replies. --Mike >My problem is fixed >on Windows 2...

Single handler for multiple controls
I think I want what, in VB, is called a Control Array. I know it can be done in VC++6 but I don't know the details of how. I have a dialog with buttons for the days of the month. I want a single handler for all of the buttons which will recieve the control Id of the actual button that was pressed. How do I achieve this? TIA, --- Al. you can use the ON_COMMAND_RANGE(commandid_start, commandid_end, commandhandler) message map for this. the prototype of the command handler is void OnMyButtons(UINT nID). the function paramer nID will contain the ID of the selected button. > you can...

what type is calendar control
running Excel 2003 (going to 2007 in the next few months) I have inserted a pop-up calendar (Insert/Object.../Calendar Control 11.0). No problems getting it to do what I want - except when I declare my variables (Option Explicit). I can't seem to determine what type the Calendar object is - Dim Calendar as Object returns a "Block Not Set" error. Any sugegstions? Art You put this calendar control directly on the worksheet, not a UserForm, correct? I think you can do it this way... Dim MyCalendar As Object Set MyCalendar = Worksheets("Sheet2").OLEOb...

Calculated control event order
Apologies if this shows up more than once - thought I had it posted but it's not showing up. I have a calculated control on a subform whose value I need to "copy" to a bound control on the main form. Can't just use [main form]!boundcontrol =subform!calccontrol because the bound control needs to be able to be edited at the users discretion (ie. the calculated value is a 'suggestion' that may or may not be what the user wants.). I can't find an event that is triggered by a change in value of a calculated field that will allow me to use code to sen...