|
You will have to do OwnerDraw.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Hi,
I am curious about OLBs and TLbs, when would you use a OLB over a TLb. Could anyone explain the difference, pros+cons etc.
Cheers
Rich
|
|
|
|
|
What is an OLB or a TLB ?
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
the .OLB extension name has been used in the past by MS along with Office, referring to their office object model. OLB stands for Object library, a way to refer to an automation-enabled object model.
the .TLB refers to a type-library, which is also an object library. But a .tlb is not necessarily automation-enabled.
Both are type libraries, generated by compiling IDL interfaces. To become automation-enabled, a type-library must expose dispatch interfaces.
A type-library is registered by its GUID in the registry (hkcr\typelib). So actually nobody really cares about the extension name you give it.
Sometimes, a type-library is even embedded in the COM server itself (as a .rc binary blob).
If that was only for the sake of semantics, you would use an .OLB extension name with automation-enabled object libraries (usable with VB, Perl, Python, ...). And you would use .TLB for all other object libraries.
VC7 doesn't change anything about it, except at design-time : you don't need an external IDL file anymore to declare type libraries.
Back to real work : D-24.
|
|
|
|
|
Is there a rule that you can not load images/cursors/bitmaps during the WM_CREATE message from the resource script.
I can load my icon from the resource file in dialog procedures, basically all other messages except WM_CREATE which is where I need it to place them on my button controls. They do load however when I use LoadCursorFromFile (for cursors)... The error code is 1813 (The specified resource type cannot be found in the image file)...Even though it does exists (Tested the same code in the WM_CTLCOLORLISTBOX message, odd place to put it I know but it was just a test, and it worked fine) This is annoying me greatly and if anyone has any feedback on this matter it would be much appreciated.
|
|
|
|
|
How does one clear all information in a list box?
Cheers
Ayush
|
|
|
|
|
SendMessage(hwnd, LB_RESETCONTENT, 0, 0);
hwnd = handle to the window (list box)
|
|
|
|
|
Hi!
The easier way to clear a listbox contents is to use the ResetContent function.
If your control member variable that represents your ListBox is m_lsXXX
then just write m_lsXXX.ResetContent();
I hope this helps
|
|
|
|
|
Hi,
In my SDI application I override menus to be ownerdrawn, and then draw them using OnDrawItem(...) of the main frame. However, i have this little problem: I click on the main menu, then a pop-up appears, I select a pop-up menu item, it displays a pop-up of next level. This second level menu partly overlaps the first one, and when it disappears the first menu doesn't get updated (part of the menu item which is selected has an unupdated trace on it). This doesn't happen with not ownerdrawn menu items.
Does anybody know what else should I do to provide all menu items get updated when necessary
Regards,
Vitaly
|
|
|
|
|
easy, only need to use 2 messages:
WM_MEASUREITEM and WM_DRAWITEM.
here is some code copied from my program, as a reference for u:
in WM_MEASUREITEM, call
void BMenuDraw::MeasureItem(int nIDCtl, MEASUREITEMSTRUCT *p)
{
NodeImage*pn=(NodeImage*)p->itemData;
ASSERT(pn!=0);
CString cs=pn->GetText();
HDC hdc=::GetDC(0);
CDC*pDC = CDC::FromHandle(hdc);
CSize size=pDC->GetTextExtent(cs);
p->itemWidth =size.cx+24;
p->itemHeight =22;
::ReleaseDC(0,hdc);
}
in WM_DRAWITEM, call:
void BMenuDraw::DrawItem(int nIDCtl, DRAWITEMSTRUCT *p)
{
CDC*pDC = CDC::FromHandle(p->hDC);
NodeImage*pn=(NodeImage*)p->itemData;
COLORREF clrBk =::GetSysColor(COLOR_MENU);
COLORREF clrTxt =::GetSysColor(COLOR_MENUTEXT);
COLORREF clrBkH =::GetSysColor(COLOR_HIGHLIGHT);
COLORREF clrTxtH =::GetSysColor(COLOR_HIGHLIGHTTEXT);
CString cs;
if(p->itemAction==ODA_DRAWENTIRE)
{
P_DrawItem(pDC,pn,p->rcItem,p->itemState,clrBk,clrTxt);
}
if(p->itemState&ODS_SELECTED)
{
if(p->itemAction&(ODA_SELECT|ODA_DRAWENTIRE))
{
P_DrawItem(pDC,pn,p->rcItem,p->itemState,clrBkH,clrTxtH);
}
}
else
{
if(p->itemAction&ODA_SELECT)
{
P_DrawItem(pDC,pn,p->rcItem,p->itemState,clrBk,clrTxt);
}
}
}
void BMenuDraw::P_DrawItem(CDC *pDC, NodeImage *pn, const CRect &rcItem, int iState, const COLORREF clrBk, const COLORREF clrTxt)
{
BOOL bDis=(iState&ODS_DISABLED)?1 ;
BOOL bChk=(iState&ODS_CHECKED)?1 ;
BOOL bSel=(iState&ODS_SELECTED)?1 ;
BImageHold*pHold=image.GetMenuHolder();
const int iBmpWH=pHold->iBmpWH;
int iBkMode=pDC->SetBkMode(TRANSPARENT);
int iX=rcItem.left+3;
int iY=rcItem.top+2;
CRect rcTxt =rcItem;
rcTxt.left =iX+24;
rcTxt.top +=2;
pDC->FillRect(&rcTxt,&CBrush(clrBk));
CDC dc; dc.CreateCompatibleDC(pDC);
CBitmap*pBmpOld;
if(bDis) pBmpOld=dc.SelectObject(&pHold->bmpD);
else
if(bChk) pBmpOld=dc.SelectObject(&image.bmpS);
else pBmpOld=dc.SelectObject(&pHold->bmpN);
pDC->BitBlt(iX,iY,iBmpWH,iBmpWH,&dc,pn->iPos*iBmpWH,0,SRCCOPY);
CString cs=pn->GetText();
COLORREF clrTxtOld;
if(bDis)
{
BYTE iClr=223;
clrTxtOld=pDC->SetTextColor(RGB(iClr,iClr,iClr));
rcTxt.top++;
rcTxt.left++;
if(!bSel) pDC->DrawText(cs,&rcTxt,DT_EXPANDTABS);
rcTxt.top--;
rcTxt.left--;
COLORREF clrTxtDis=::GetSysColor(COLOR_GRAYTEXT);
pDC->SetTextColor(clrTxtDis);
pDC->DrawText(cs,&rcTxt,DT_EXPANDTABS);
}
else
if(bChk)
{
BYTE iClr=223;
clrTxtOld=pDC->SetTextColor(RGB(iClr,iClr,iClr));
rcTxt.top--;
rcTxt.left--;
if(!bSel) pDC->DrawText(cs,&rcTxt,DT_EXPANDTABS);
rcTxt.top++;
rcTxt.left++;
pDC->SetTextColor(clrTxt);
pDC->DrawText(cs,&rcTxt,DT_EXPANDTABS);
}
else
{
clrTxtOld=pDC->SetTextColor(clrTxt);
pDC->DrawText(cs,&rcTxt,DT_EXPANDTABS);
}
dc.SelectObject(pBmpOld);
pDC->SetBkMode(iBkMode);
pDC->SetTextColor(clrTxtOld);
}
in code above, i used menu image (NodeImage), u just modify it a little, must be well.
includeh10
|
|
|
|
|
hi everyone,
I read the article "Printing Made Easy with MFC" and am using the GPrintUnit and GPrintJob classes.
I would like to know how to redefine the Rect for printing, or more specifically how to introduce a margin so that my printing does not start on the edge of the page.
Thanks in advance
Regards
Rui
|
|
|
|
|
|
Thanks for the article, it does explain quite a bit on printing.
But I was wondering more about where to set the JRECT defined in the classes GPrintUnit and GPrintJob?
Although I am going to try to override the GPrintInfo function and set the JRECT there. I am not sure if this is correct.
Thanks
Rui
|
|
|
|
|
hi,
I defined a message in *.exe. And in *.dll, I trigered the message, nothing happened. tell me why.
Note, this message works well in *.exe
Thanks in advance
Extreme programming. Do the No.1
|
|
|
|
|
Did you add a command handler for that message?
Best regards,
Alexandru Savescu
|
|
|
|
|
Are you sending the message to the correct window?
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Is there any application written in VC++, regarding voice communication, you aware of; then please let me know.
There is one here at CP, but it gives lot of echoes and code not of good quality. If there any other present somewhere like MSDN or M$ research site, you aware of then please let me know.
BTW: i've already searched google but it is giving results that are either Unix related or difficult to compile in VC++
|
|
|
|
|
If you want to add Text-To-Speech then get the SDK from Microsoft, there are many examples in C++ which work well.
Old Simon HB9DRV
|
|
|
|
|
No, I don't want anything like text-to-speech. What i want is to transfer voice over lan/internet in peer-to-peer or client/server manner
|
|
|
|
|
There is example voice chat software in the DirectX SDK
--
Help me! I'm turning into a grapefruit!
|
|
|
|
|
hi all,
i found this error when i include 2 header files in each other's header file. i do this since i need to call each other's functions with pointer to link to these objects.
class A
{
public:
...
..
private:
B *b;
};
class B
{
public:
...
..
private:
B *b;
};
how can i solve this problem?
thanks!!!
chaze
|
|
|
|
|
the class declaration should like this!
class A
{
public:
...
..
private:
B *b;
};
class B
{
public:
...
..
private:
A *a;
};
|
|
|
|
|
Well, you include A, it includes B, it includes A, it includes B....
This sort of stuff messes with your build times as well. Do this:
a.h:
class b{};
class a
{
...
a.cpp:
#include "stdafx.h" // always at the top
@include "b.h"
and vice versa. You're telling the compiler that b is a class, it can worry about the rest later - this works because all you're storing is a pointer, it does not need to know any details about it until it gets to the implimentation ( the .cpp file)
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
hi,
your solution seems don't work... the compiler complain that redefine a class...
anything wrong with me?
|
|
|
|
|
don't include a.h from b.h (and vice versa)
--
Help me! I'm turning into a grapefruit!
|
|
|
|
|