|
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
|
|
|
|
|
See if this class helps.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
Sorry my question is long. I try to use colour and fonts to make it clear.
I have a class and I now want to make a list of my objects and so I want to make a class which is a list of my objects.
So I have my object: CMyObject
My list of my objects: CMyObjectList
CMyObjectList has a CList member which is declared like this:
CList <CMyObject, CMyObject> m_ObjectList;
I have a member function in my CMyObjectList class called addMyObject() .
Now my question: should I add a CMyObject instance by pointer or by reference? When I add CMyObject to my list should I create a new object in the add() member function so that my caller can delete his copy or allow it to go out of scope? Does the CList addToTail() function create a copy? What is good form for this sort of problem? Should the list create a completely new object to store or should the client make sure the object is not deleted or go out of scope?
Example:
...
CMyObjectList myList;
CMyObject myObject;
myList.add(myObject)
myList.add(&myObject)
...
CMyObjectList.add(CMyObject myObject)
{
...
}
CMyObjectList.add(CMyObject *myObject)
{
...
}
Thank you.
|
|
|
|
|
My recommendations are as follows:
If you don't expect to derive classes from CMyObject, and all the objects you want to store are independent from each other, I would use a CList< CMyObject, const CMyObject& > . Specifying the second parameter as a const T& means that the compiler won't make a copy of the object simply to call the function. For a simple object (one smaller than 4 bytes), use CList< T, T > instead, since the copy is trivial.
If you need to be able to invoke virtual behaviour through the list, or store objects derived from CMyObject in a CMyObjectList, use a CMyList< CMyObject*, CMyObject* > . Also do this if you might need to refer to the same object at two different positions in the list, or if copying your objects will break any object relationships you may have.
CList always stores a copy of the object that is passed to AddToTail (in the pointer case, it copies the pointer).
I prefer to store actual objects in the list in the simple case, because it's a lot easier to manage.
|
|
|
|
|
hello everybody,
my project module is to develop a graphical language in vc++. we have to declare a few keywords,graphical routines,looping statements etc.
Using the syntax that we declared earlier, telling the user to follow that syntax to code it.
My problem is, how can i define these langauage primitives and compile it to produce the output.
FOr example,
the user code in editor,
# start
text "Mahe" 123 232 Bold
cirlce 232 232 21
line 232 232 232 121
# stop
our compiler(VC++) has to read all this code and produce a graphical output.please guide me for , how to analyze this project.
first i have to spec it out the language keywords etc and all...please suggest me to workout this project
Mahesh Kumar,b'lore
|
|
|
|
|
Hello!
If grammar in your language is simple
You must learn about(as minimal) regular expression:
http://www.codeproject.com/cpp/OwnRegExpressionsParser.asp
if grammar in your language is difficult(above 50 grammar rules), you must learn compiler design theory and use compiler-of-compiler for example yacc.
|
|
|
|
|
I know this may be an easy beginner question but it drives me crazy and I've alredy spent 3 hours on this.
I added the followilng libs to the linker:
d3dxof.lib
dxguid.lib
d3dx9dt.lib
d3d9.lib
comctl32.lib
winmm.lib
and the included files:
#include "./Common/d3dfont.h"
#include <windows.h>
#include <d3dx9.h>
#include <stdio.h>
Now I'd like to create a global font:
static CD3DFont* Font1 = new CD3DFont(_T("Arial"), 20, D3DFONT_BOLD);
static CD3DFont* Font2 = new CD3DFont(_T("Arial"), 10, D3DFONT_BOLD);
when I compile the whole thing the linker gives me an LNK2019 error, unresolved external symbol.
I think I've had the same error when I first used a dx-function, but I could solve the problem with the right lib-file.
I searched through the Text3D-example of the sdk but I can't find the point my project file is missing
|
|
|
|