|
Hi,
I am struggling to create a decent-looking toolbar using the Windows API with no MFC (it may well be easier with MFC if you know it, but I have yet to plough through my MFC books and I don't want to port the whole of my nearly-finished current project).
After struggling for a couple of days to get a 'flat' look (using TBSTYLE_FLAT) without having all the buttons become transparent, I discovered that to get the look I wanted, I needed to use Rebars. I used the code from MSDN (here) to create a test rebar, and it gave me the look I wanted - except that it is still screwy in another way (probably because MSDN assumes two other functions that it doesn't provide - CreateToolBar() and CreateComboBox()). Essentially, I want two rows of toolbars, so I figured that I would need to create two toolbars and two 'bands' in my rebar to hold them (ie. two calls of RB_INSERTBAND with the RBBS_BREAK style. I have successfully set up my test proggy so that it has two bands of the correct size, but the problem is that the toolbar buttons that should be on the second band aren't in the right place - they overlap the toolbar buttons on the first band (ie. both toolbars seem to have been created at window co-ords 0,0).
I can better explain what I mean by posting a picture:
Picture Here
The CPP file for this test proggy can be downloaded here - this is the only file of the project, so can be compiled to the test prog. It's messy because it's just a test program that I threw together to try and get rebars and toolbars working. CreateRebar() was ripped from MSDN, with only minor modifications. The problem might be there, or it might be in CreateToolBar() (which creates a toolbar with three text buttons) or CreateToolBarIcons() (which creates a toolbar with some standard Windows buttons). I've stared and stared, experimented, tested and generally poked around, but I just can't see what I'm doing wrong.
If anybody has a chance to scan these functions to see what my mistake is, or just make some suggestions as to what you might think the problem could be, I would really appreciate it. Obviously I don't expect anybody to debug my code - I only attach the CPP file because it is easier than posting three long functions here.
Many thanks to anyone who can help,
KB
|
|
|
|
|
P.S. Depending on what version of comctl32.lib you are using, you may have to change MIIM_STRING to MIIM_TYPE to get main.cpp to compile - or just comment out the whole of CreateMenu() as it has nothing to do with my toolbar problem anyway.
Any replies or help much appreciated!
Many thanks,
KB
|
|
|
|
|
Has anyone seen an implementation of an outlook bar control but that is horizontal, not vertical? An example of a vertical one is:
http://www.codeproject.com/cs/miscctrl/csoutlookbar.asp?target=outlook%7Chorizontal
I am looking for this control written in C++ not C# but would take either.
Thanks
Ralph
|
|
|
|
|
I have a CButton-derived class that is owner-drawn and has data members for a pointer to a CImageList and an index to select which image in the list to display. The bitmap resource that is used to create the ImageList is 8-bit and uses green as the background color to be masked. When I draw the images onto the button, the transparency mask works great, but the rest looks bad, like it might be a 4-bit image? Yet it looks fine in the resource editor. I'm missing something crucial.
Thanks in advance for any advice.
Tym!
Here's what I'm doing more or less:
The image list is created from a resource: an 8-bit bitmap strip with a green background for the masked transparent color:
<br />
CImageList _defaultImages;<br />
_defaultImages.Create(IDB_BITMAP_RESOURCE_ID, _imageWidth, 32, 0x0000ff00);<br />
The Button is created dynamically:
<br />
#define BTN_STYLE BS_PUSHBUTTON|WS_VISIBLE|WS_TABSTOP|WS_CHILDWINDOW|BS_NOTIFY|BS_OWNERDRAW<br />
...<br />
CMyButton* _myButton = new CMyButton();<br />
_myButton->Create("",BTN_STYLE,_buttonRect,this,3999);<br />
_myButton->SetImageList(&_defaultImages);<br />
_myButton->SetImageIndex(DEFAULT_IMAGE);<br />
and I am drawing the image like so:
<br />
void CMyButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) <br />
{<br />
<br />
CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);<br />
UINT state = lpDrawItemStruct->itemState;<br />
...<br />
if (_imageList != NULL && _imageIndex != -1)<br />
{<br />
CPoint _location(2,2);<br />
if (state & ODS_SELECTED)<br />
_location.Offset(1,1);<br />
<br />
this->_imageList->Draw(pDC, _imageIndex, _location, ILD_TRANSPARENT);<br />
}<br />
...<br />
}<br />
|
|
|
|
|
I found it.
When creating the imagelist directly from the resource, the ImageList defaults to 4-bit apparently. So I has to do it the long way:
<br />
CBitmap _imageBitmap<br />
_imageBitmap.LoadBitmap(IDB_BITMAP_RESOURCE_ID);<br />
<br />
CImageList _defaultImages;<br />
_defaultImages.Create(_imageWidth, _imageHeight, ILC_COLOR32|ILC_MASK, 1, 32);<br />
_defaultImages.Add(&_imageBitmap,0x0000ff00);<br />
This will create a 32-bit imagelist with a green mask from the resource.
|
|
|
|
|
Hello,
I create dynamic Window triggering on a mainframe event using:
CMDIChildWnd::Create(lpszHelloClass, szTitle, style, rect, parent);
As I create each new window, I want to load a dialog resource, the same resource for each new window.
How do I do this? I will be adding an ActiveX control to the dialog.
Thanks.
Jerry
|
|
|
|
|
You can create a CDialog derived class holding the functionality of the dialog resource. Ofcourse you should be having the resource id of the dialog at compile time itself for doing this.
After this you can use one of your events to invoke this dialog by calling CDialog -- DoModal().
You can probably refer this link to get some more ideas.
http://www.codersource.net/codersource_mfc_prog.html
This might give you some idea.
|
|
|
|
|
Does anyone know of a library for loading (and possibly displaying) MS PowerPoint files? I need more control over the presentation than COM allows.
Thanks,
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
You could host it in a WebBrowserCtrl.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
I am using a manifest to load Comctl32 v6 when the application is loaded on Windows XP. However, I get a weird paint problem when I use AppName.manifest.exe vs. when I don't use it.
http://www.sagara.org/goodbad.gif[^]
(Good == without AppName.manifest.exe; Bad == with AppName.manifest.exe)
Has anybody seen this behavior before?
|
|
|
|
|
Yeah, it's a known issue. I'll bet you're using VC6 ?
You need to send the toolbar a WM_NCPAINT message when it re-paints itself:
::SendMessage(m_wndToolBar.GetSafeHwnd(), WM_NCPAINT, 0, 0);
|
|
|
|
|
LunaticFringe wrote:
I'll bet you're using VC6 ?
Indeed I am. Is this specific to VC6? Do you by chance have a link to a KB article?
BTW, thanks for the response.
|
|
|
|
|
No, I don't have a KB. I meant it was known to me. (Big whoop, says Jon.)
No, trivial as this seems, it was one of the final straws in convincing me to upgrade to VS.NET 2003. This isn't a problem there.
If you use toolbar customization, though, this is still a problem, even in MFC ver. 7.1. They fixed the regular paint problem, but not one that occurs when the bar is resized as buttons are added or removed. Same fix applies - you just add a NCPAINT call.
You might try deriving a class from CToolbar and adding this to the WM_PAINT handler.
<edit>
Naa, forget that suggestion. You'd have to make (well, should make) the execution conditional on it running on an XP box, using themes, and all the rest of it. Nope, you're looking at just what I was looking at. Either upgrade or abandon the use of themed controls.
</edit>
|
|
|
|
|
I have a C# application where I want to allow runtime resizing and moving of controls. The functionality that I need is encapsulated in the C++ class CRectTracker. I need to reference the MFC library, but also provide a callable interface from C#. I have tried to create a managed C++ dll, but it does not create the linkages to the MFC library. Would it be better to create an MFC C++ dll, and then wrap the interface with managed extensions? I'm not sure how to go about the second option. How do I reference a CWnd object from C#? Any help would be appreciated.
|
|
|
|
|
This is a Winsock question.
I have a TCP server application that is listening for connections on port 9000. When the client application connects I do an accept(). If I look at the port number of the socket returned by accept I see a semi-random port number. My question is, can you specify what this port number will be? If I want my client port numbers to start at 9001 and go to a max of 9500, can I programatically do this? I have searched the Winsock API but I have not found an example.
Thanks
|
|
|
|
|
Hi, you can specify the port on the client side like this...
//set port to 5001, not set by user
sockaddr_in clientService;
clientService.sin_family = AF_INET;
clientService.sin_addr.s_addr = inet_addr(HostIPAddress);
clientService.sin_port = htons(5001);//<-set IP port here
I dont know if this helps you.
Good luck.
Jerry
|
|
|
|
|
If I can ask -- what's your motivation for controlling the client-side port?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
Hi all,
I need to have a CSplitterWnd class to be embedded in a CView class. (I know it is weird, but due to my constraints I have right now, this seems to be the only choice.) I wonder is it possible of doing this?
I try to create a CSplitterWnd with the parent MainFrame, create its own CCREATECONTEXT. It is fine up to this point. But, when I call subclassDlgItem () to make it become the child of my CFormView, the result is that the whole splitter Wnd disappear.
I wonder if anybody has done this before.
Thank you.
|
|
|
|
|
Jimmy Chu wrote:
I need to have a CSplitterWnd class to be embedded in a CView class. (I know it is weird, but due to my constraints I have right now, this seems to be the only choice.) I wonder is it possible of doing this?
You can't put it in the CFrameWnd -derived class?
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Seems like you are not designing the code properly, Coz if you do it will work out fine... spliterwindows needs to go into CFrameWnd derived class.
Prakash,
India.
|
|
|
|
|
Jimmy Chu wrote:
I need to have a CSplitterWnd class to be embedded in a CView classAnd
And this doesn't work? CSplitterWnd only takes a CWnd* as parent. It does not need a CFrameWnd* .
Can you further explain your design and maybe post a (stripped down!) code fragment?
I am under the impression what you want is possible, and you are maybe doing a small mistake.
"We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation."
-- Caius Petronius, Roman Consul, 66 A.D.
|
|
|
|
|
We have a main project called "Alphabet". It contains three sub-projects called "A", "B", and "C".
We now have a new subproject we call "D".
The "Alphabet" project now contains a compiler definition in the project settings called "NEW_ALPHABET".
We want to compile the "Alphabet" project so that by including or omitting the "NEW_ALPHABET" definition, we can compile and link in either "B" or "D", but not both.
Can this be done, and if so, how?
------- sig starts
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
"You won't like me when I'm angry..." - Dr. Bruce Banner
Please review the Legal Disclaimer in my bio.
------- sig ends
|
|
|
|
|
Can't you use some preprocessor code in Alphabet's stdafx.h file?
Something like:
<br />
#ifdef NEW_ALPHABET<br />
<br />
#pragma comment(lib, "B.lib")<br />
<br />
#else<br />
<br />
#pragma comment(lib, "D.lib")<br />
<br />
#endif
You'll have to have the correct header files included, and have the directories where those headers and lib files live included in the project settings.
|
|
|
|
|
Yeah this can surely be done.
What you do you had a new project settings by Build->Configuration.
You simple need two sets of entries one that involves B and other that involves D for compilation and linking.
Do the appropriate changes in the project setting to link the proper libraries... And also set the appropriate dependancies.
this way you will ignore the build of the project that is needed and plus you will not have any confusion during each build on which lib file was linked.
Prakash,
India.
|
|
|
|
|
new to makefiles.
Heres my problem:
I used an xstring (custom) object in a class myClass, which has a functionality test fMyClass. In the makefile I did:
fMyClass.x: $(proj)/fMyClass.o myclass.o
$(CC) -o fMyClass.x fMyClass.o myclass.o
fMyClass.o: $(proj)/fMyClass.cpp
$(CC) -c $(incpath) $(proj)/fMyClass.cpp
myClass.o: $(proj)/myclass.h $(proj)/myclass.cpp $(cpp)/xstring.h $(cpp)/xstring.cpp
$(CC) -c $(incpath) $(proj)/myclass.cpp $(cpp)/xstring.cpp
and it gives me errors like:
Undefined first referenced
symbol in file
operator<<(ostream &, XString const &)myclass.o
XString::~XString(void) myclass.o
XString::XString(char const *) myclass.o
I do have xstring.h included in myclass.cpp.
What do I need to fix here? The fMyclass doesnt use xstring, but myclass does.
thanks,
ns
|
|
|
|
|