|
Dear MFC Gurus!
I'm writting SDI-based application that has DialogBar with combobox control. This DialogBar is initialized as the follows:
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
...
if (!m_Bar.Create(this,IDD_BARDLG,CBRS_TOP,ID_MYBARDLG)) {
AfxMessageBox(_T("Failed to create dialog bar!"),MB_ICONSTOP);
return -1;
};
};
where m_Bar is CDialogBar. IDD_BARDLG doesn't have its class derived from CDialog!
How to capture ON_CBN_SELCHANGE message in CMainFrame class from combobox control belonging m_Bar? In other words, I need to track changing the selection of combobox. What should I do?
Yours sincerely,
Alex Bash
|
|
|
|
|
Trap it in your dialog bar. Then, post a command (eg: CMD_CHECK_COMBO ) to the mainframe that causes it (the mainframe) to check the selection of the combo.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
What is "trap"? I'm not sure about terminology...
Yours sincerely,
Alex Bash
|
|
|
|
|
What I meant was write a handler for the CBN_SELCHANGE notification.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
I've got a custom control that I am implementing that behaves much like a combo box. When the user clicks the down arrow button, an new window is displayed that presents a Color Selector much like the one in MS Office. I've based the code loosely on articles found here on CodeGuru, with modifications for my specific requirements. Now I've got everything working fine but one that that is causing me trouble is that when the Color selection drop down is shown the control gets a killfocus message. I don't really want a
kill focus message to go out since my control hasn't really lost focus, its just given it to is dropdown window.
Looking at SPY I see that the normal combo box doesn't send out a kill focus when the dropdown is opened so there must be a way to trap the message.
Does anyone know how I can keep my Control from sending a kill focus when the Dropdown window is shown?
My class is derived from CButton.
Thanks
Timothy Bish
tabish[at]twcny.rr.com
timothy.a.bish[at]lmco.com
|
|
|
|
|
tabish121 wrote:
Does anyone know how I can keep my Control from sending a kill focus when the Dropdown window is shown?
I don't think you can prevent this. But your control could just ignore the WM_KILLFOCUS (or at least handle it differently) if the color selector window is being displayed.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
The problem is that the control is being used as an in-place control in a List Ctrl, and when the control looses focus it is destroyed by the list control. I've thought up some hacks to work around this but I just figure that there must be a way to make this behave more like CComboBox, which doesn't send a Kill Focus when the list is opened.
Thanks
Timothy Bish
tabish[at]twcny.rr.com
timothy.a.bish[at]lmco.com
|
|
|
|
|
Is window that is being popped up a child of the CButtonCombo class? If not making it a child may solve your problems.
If it is the child, the CListCtrl OnKillFocus() handler needs to check that the window receiving the focus is not a child window of the combo box. If it is, then is does not destroy the control.
Roger Allen - Sonork 100.10016
Roger Wright: Remember to buckle up, please, and encourage your friends to do the same. It's not just about saving your life, but saving the quality of life for those you may leave behind...
|
|
|
|
|
Yes, the popup window is a child of the Buttom Combo class, which was what I thought would help to avoid the Kill Focus event being sent, but apparently not. I think I've come up with a solution that should work, its not the most elegant, but at least it should solve the problem.
Thanks for the input.
|
|
|
|
|
can any 1 show me how i can read n send chunks of a bufffer at a time?
size = file.tellg();
file.seekg (0, std::ios::beg);
long filesize;
filesize = size;
char sizebuf[50];
ltoa(size,sizebuf,10);
send(newsock,sizebuf,strlen(sizebuf),0);
long sent = 0;
long sizee = filesize/10;
long marker = 0;
long final;
do{
//file.seekg (marker, std::ios::beg);
file.read(buffer + marker,sizee);
//file.get(buffer + marker,sizee);
sent = send(newsock,buffer,sizee,0);
marker = marker + sent;
// }while(final <= filesize);
}while(!strcmp(buffer,"eof"));
thanx
|
|
|
|
|
First, tellg gets the current position, you should move the pointer to the end of the file and then use this to get the file size. Then move the pointer back to the top (which you have done.)
Then determine the size that you want to read (chunk). Then call the read method with the buffer and the number of bytes you want to read.
file.read( buffer + marker, size );
Then mover the marker:
marker += chunk;
Continue doing this until you have read in all the bytes or until the file.eof() is true.
You may also want to surrond this in a try-catch incase there are any problems reading.
Larry J. Siddens
|
|
|
|
|
Hey everyone,
I am kind of confused about something. I had written some code using MFC called say test.cpp. I put it in a folder with the same name. It worked fine. It was just a basic cout statement. I then deleted the folder and tried to write another piece of code named the same thing (test). When I did this it told me that it could not be executed. I then copied some code over from a cd that came with my mfc book and tried to compile it on my c drive and it did not work. I then put the code in a new directory and compiled it there and it worked fine. I have no idea why this code works in some places and not others and if I delete a file and then rewrite new code with the same name why that doesn't work....can someone help me??? I am kind of new at this so let me know if I am not explaining myself well.
|
|
|
|
|
It's a good idea to use fully qualified filespecs i.e. drive:\path\filename.ext rather than just filename.ext in your code. The latter can cause problems with different invocations of the same program, depending on Window's current default directory.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
I am trying to add a member to a listbox in VC .NET dialog project to add a list of string entries (m_list.AddString("A")).
In VC 6 MFC it's a matter of right clicking the list box and selecting classwizard, member variables and selecting add variable.
In doing the same in .NET (Right click list box, add variable) and before adding any code and just compiling, I get the following error:
"Unhandled exception error at 0x00000000 in project.exe: 0xC0000005: Access violation reading location 0x00000000."
I even created a brand new Dialog project and just added a list box, added the member and get the exact same error msg! Doing it in VC 6 MFC, it works a treat!
Also can any one offer advice on how using VC++ .NET (MFC App) to take 'focus' of a button and its associated menu item on selection of another button and its associated menu item.
For example, I have two projects one being Single doc and the other a dialog based. They each do the same thing, however on
selection of Button A (or its corresponding menu Item in Single doc):
1. In the single document I need to take focus (i.e. Grey out) off 3 buttons on the toolbar and their corresponding menu items.
2. Same above for the dialog project, only instead of buttons it is a list box and there are menu items.
I thought in the Update Command for ButtonA I could simply add something like:
pCmdUI->Enable(!button1)
pCmdUI->Enable(!button2)
pCmdUI->Enable(!button3)
However this just disables Button A! I then tried adding:
If (checked)
pCmdUI->Enable(!button1)
to all of the buttons Update Command function that would have the variable 'checked' set to true by action of code in Button A's Command function. However this only worked if the button to be greyed was selected after Button A was.
Any ideas??
TIA
|
|
|
|
|
sallas wrote:
I get the following error:
"Unhandled exception error at 0x00000000 in project.exe: 0xC0000005: Access violation reading location 0x00000000."
Which line of code gives that error?
sallas wrote:
pCmdUI->Enable
Only allows you to enable/disable the item that function was called for. If you want to disable/enable other controls you'll need to write your own code.
Are they CButton buttons or are on they on a toolbar?
For buttons and the listbox
GetDlgItem(IDC_MYCONTROL)->EnableWindow(FALSE); //will disable the control
Michael
But you know when the truth is told,
That you can get what you want or you can just get old,
Your're going to kick off before you even get halfway through.
When will you realise... Vienna waits for you? - "The Stranger," Billy Joel
|
|
|
|
|
The funny thing is that the code compiles without any errors, yet it is on running the program that i get this error. If I 'start' the project without debugging, it never runs. It is when I 'start' the project with 'debugging; that it brings up the prementioned error. The only way I can prevent the error is by commenting out the declaration of the variable that I added (which through the class wizard is automatically implemented). The class wizard adds it to the Dlg.h file.
The GetDlgItem(IDC_MYCONTROL)->EnableWindow(false) works fine for a dialog based project, but what about a single document project? On selection of a CButtom or its corresponding menu item (ie File->open) how do you disable/grey out other CButtons and their corresponding menu items wherby there is no dlg file? (I believe it to be say, m_variable.EnableWindow(false) but am ,as stated above, unable to run the project with a variable added)
|
|
|
|
|
Try m_list.Items.Add( "" );
Larry J. Siddens
|
|
|
|
|
Hi Guys,
This is my first post here.
I am facing some problem. I have a dialog based application in which i have
3 buttons namely <temp internet="" files,="" cookies="" &="" history=""> and a list box.
Now as the user clicks on the respective button i want all files belonging
to that folder and sub folders with in to b displayed in the listbox.
I am using SHGetSpecialFolderPath() to retrieve the path.
I have already tried using the functions <findfirstfile()> &
<findnextfile()>but to no use.
I think Temporary Internet Files, Cookies & History are shell folders and
needs to be accessed in different manner?
Waiting for suggestions
Regards.
|
|
|
|
|
Hi all,
I tried to get/set the position and size of a ListCtrl in a dialog. When i use the GetClientRect() method i get no values and the programm crashes and starts the debugger. Is it the same way if i want to change the position of buttons and so on?
Is anybody out there who can help me with this problem and explain it to me!? (MFC)
Thanks
P.R.
|
|
|
|
|
Try:
RECT stItemRect = {0};
GetDlgItem(IDC_NAME_OF_CONTROL)->GetWindowRect(&stItemRect);
This ensures that you are using the correct CWnd item. It gives you all the corners of the item, so you can also work out the size.
If this still crashes then I would guess the list control is being declared incorrectly - does it display on screen with those lines commented out?
Simon.
|
|
|
|
|
Wee - Man wrote:
When i use the GetClientRect() method i get no values and the programm crashes and starts the debugger.
Can you provide a code snippet of what you are doing?
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
I need some help with a Visual C++ speech application using Speech SDK. I can't select other installed voices because of the language and I don't know how could I do it.
Please, I need it
Thank you in advance!
I have no idea
|
|
|
|
|
Hi all,
Please clarify my doubt.
In my application i created the buttons using CBitmapButton class. Using the method LoadBitmaps() i load the bitmap over the button.
I need to load the Bitmap over the button as per the button size... ie., how to stretch the bitmap and loaded to the button...
Or is there any other way to implement this ??
Thanks and Regards,
Prakash
A Journey of thousand miles must begin with a single step.
|
|
|
|
|
Owner draw the button and
use StretchBtl(...)
to stretch the bmp
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
Try CButtonST class. It has some memory leaks. But good control
|
|
|
|