I have a dialog which I use as a toolbar. On this dialog are drawn buttons using the CreateWindow function so that they can be drawn dynamically and they are sent the BM_SETIMAGE so that I can draw a different bitmap on each. This all works fine, I can add and remove buttons anywhere I want on this toolbar dialog. This is probably a really simple question, how do I handle them being pressed? Thanks for any help in advance, Nick :confused:
Nick Armstrong
Posts
-
Message handling -
Focus problemI was actually using the splash class wrongly and putting a line of code in the wrong place (doh), thanks for the help though, Nick :)
-
Focus problemI have an application that shows a splash screen for 5 seconds, the splash screen is deleted and a dialog box should be shown. The problem I had was that the dialog box would be behind everything else (the edit box inside the dialog would still have focus, which is correct). To solve this, in the OnInitDialog of the dialog I set the window position and size etc and set the first parameter to wndTopMost. This worked up to a point. The dialog is now on top and the cursor is flashing in the edit box where it should, BUT the box itself still doesn't have focus and you have to click on it before you can type in the edit box. Any ideas how to rectify this? Thanks in advance for any help, Nick
-
CHtmlView questionyep just found it, cheers anyway :) Nick
-
CHtmlView questionI am using an CHtmlView in my application and was just wondering whether you could do something or not. Is it possible to know when a user clicks on a hyperlink? I'll explain why I wish to do this for a bit more background. The user open's up a record which is an html page generated from a text file that is stored on the local disk. Depending on certain criteria, hyperlinks are built in to this record. Because this page is generated automatically I want to be able to track which hyperlink is clicked on so I can generate the relevant destination page automatically so I don't have to store (potentially) lots of html files on the local disk. Any ideas? Thanks for any help or suggestions in advance, Nick
-
Ticks in menusthanks, that worked and I have been able to open and close this dialog from the view menu with the tick being displayed/hidden but how do I get the tick in the menu to disappear when the dialog is closed using the close button on the top-right of the screen. I can handle it using OnClose() in the dialog's class but how do I link it to the menu. thanks for your help so far, Nick
-
Ticks in menusWhen I created my SDI aplication it gives you the choice of having a status bar, if you select yes to this, when your program is created it creates a View menu with a status bar option inside. When you click on this option, a tick appears next to this if the status bar is shown and disappears if not. I wish to copy this functionality with another menu item but cannot work out how it does this in my program, any ideas? Thanks in advance for any help, Nick
-
Button backgroundOk, thanks, I suppose I can get around it by altering the bitmap itself to have a white border or something, I'll work on that. The reason I wanted to do it was because some of the bitmaps I was drawing had a grey edge on some sides which was the same colour as the button itself so the border wasn't showing. Thanks anyway, Nick
-
Button backgroundI am creating buttons dynamically in my dialog box by creating them as windows using CreateWindow and putting bitmaps on top of the buttons. This works fine, however, I want to change the background colour of these buttons to a lighter colour. I'm guessing that I use SendMessage but as to which message and parameters I'm lost. Could anybody point me in the right direction. I've checked some articles but they are geared more to using the resource editor or owner-drawn buttons. Thanks in advance for any help, Nick
-
CreateWindowSorted, thank you very much, much appreciated. Nick :-D
-
CreateWindowSo for example, I could set it as 966 by doing int hButton = 966; and including hButton under/after the m_hWnd parameter, because I already tried that. If that is correct, there is something else wrong, probably in the loading of the bitmap because when the program is run it show's no bitmap on the button. Nick
-
CreateWindowHow do I get this child window ID? So far I have the following code: CreateWindow( "BUTTON", "sample", WS_CHILD | WS_VISIBLE | BS_BITMAP, 5, 5, 20, 20, m_hWnd, /*the child window ID will go here*/, NULL, NULL); HBITMAP hBmp = (HBITMAP)::LoadImage(AfxGetInstanceHandle(), "c:\\1.bmp", IMAGE_BITMAP, 16, 16, LR_LOADFROMFILE); ::SendMessage((HWND)hButton, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hBmp); Thanks for the help so far Nick
-
CreateWindowthanks a lot, that worked fine Nick :-D
-
CreateWindowthanks, but do I put those in the constructor of the containing dialog because obviously the buttons will be part of this. When doing this I get an assertion error, I think its talking about a NULL handle to this dialog which I thought would be a problem. Nick
-
CreateWindowI have a dialog which I have set as a tool window so it is always on top. Within this window I want to dynamically load buttons each with a different bitmap on. Someone has suggested that I use CreateWindow and pass a flag to say it will be of style BUTTON so I use the following code CreateWindow("BUTTON", "sample", BS_BITMAP, 5, 5, 100, 100, m_hWnd, NULL, NULL, NULL); I'm assuming that m_hWnd member variable should be a handle to the dialog box when it is shown, but when tested comes through as NULL and nothing is shown in the dialog box. What am I doing wrong? Thanks for any help in advance Nick
-
Suggestions about bitmap buttons requiredI am building an application which has similar (limited :) ) functionality to an art package. The main screen is a grid with different bitmaps that are loaded dynamically to form maps. As well as this main screen there is a floating tool window (which at the moment is empty), that I want to house the bitmap palette, a bit like a colour palette in a normal art package. The map's use a lot of different bitmaps and so I have included a menu on the top of the tool window dialog so that different palettes will be able to be loaded. Another thing I wish to implement is a scroll bar in this tool dialog, again because there are going to be a lot of different bitmaps available. What do people suggest I do to handle the selecting of different bitmaps on the tool window. At the moment I am trying to implement them using buttons with bitmaps instead of text, problem with this is that I cannot find any examples of dynamically loading these bitmaps from files to go on the button, just resources. Is there a better way of doing things with this tool window than this? Any suggestions will be greatly appreciated Nick :)
-
SerializationI am creating a SDI application. The document keeps track of a single instance of a grid class which I need to save the state of. I have derived the grid class from CObject and am using the Serialize member function of the document class. My problem is that it does not seem to save anything of the user-defined grid class. I tried just saving an int value as well to make sure that it was actually serializing properly and it was. I derived my class (Grid) from CObject and placed the line DECLARE_SERIAL( Grid ) in the public section, and finally placed IMPLEMENT_SERIAL(Grid,CObject,1) at the bottom of my document class but no joy. Any ideas as to what I'm doing wrong? Thanks for any help in advance Nick :confused:
-
Bitmap QuestionThx a lot, looks like this'll work Nick :-D
-
Bitmap QuestionI have a doc/view program (sdi) and I want to be able to load and display bitmaps on the fly from .bmp files. I have an array of cells that the document keeps track of and I want the view to draw the correct bitmap who's filename will be stored in the cell object so that when OnDraw is called it looks up which bitmap it should be displaying and loads and displays it, opposed to having the bitmaps as resources. I have gathered that to load a specific bitmap you use the code... HBITMAP hImage = (HBITMAP)LoadImage(NULL, "c:\\nick.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE|LR_DEFAULTSIZE); but I cannot work out how to display it because everything I blit to the screen is blank. I've checked and the bitmap is loading ok, just not displaying. How do you do this? Cheers for any help Nick :confused:
-
Scroll barsI have created a window inherited from CFrameWnd using the create function and I use WS_VSCROLL to stick a vertical scroll bar on the right edge. I want to be able to code the movements of the user clicking on the scroll bar etc and the movement shown withing the bar, my problem is what is the scrollbar called so I can call member functions such as GetScrollPos() etc. I have tried the method OnVScroll and used the pScrollBar parameter but this only comes up with a run time error as if it were null which I think it is. cheers in advance Nick