|
GetStockObject(SYSTEM_FONT)
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
I'm trying to use CImage in an ATL Active X. I only use methods from CImage Load, Draw and Destroy (which is noting strange). The problem is that when the application that uses the control ends, the DLL of the control can be unload. Any idea of what's the matter ?
|
|
|
|
|
I have two List Control boxes in a dialog. and I wish the user can select a few items from the first list and some items from the second list, and then the user can see all the items he just chose are still highlighted in both lists.
now after i selected one or some items in the first list(they'll get highlighted at this time), when i click in the second list and select items there, the first list will lose focus and the highlighted items in the first list will lose highlighting. Anybody can suggest me how to solve it? thx a lot in advance.
|
|
|
|
|
Just a guess, but the list view control has a 'Show selection always' property...
If that doesn't do the trick then you'd have to devise something using owner draw...
Either way only one item can ever have focus so I hope you don't desire the focus rectangle also...?
Cheers!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
hi Hockey?!, ...
thx a lot for ur tips! i tried to use the property of 'Show selection always', it works!
only thing now is that the highlighted color turns from blue to gray once the list losing focus. anyone got any idea about still keep it in blue besides using owner draw?
thx a lot again!;P
|
|
|
|
|
You will have to add a message handler OnCustomDrawList to your listCtrl class
using
ON_NOTIFY(NM_CUSTOMDRAW,IDC_LIST_CTRL,OnCustomdrawList)
Check out an article by Michael Dunn at
http://www.codeproject.com/listctrl/lvcustomdraw.asp
You will also find some similar implementations(of OnCustomDraw) on www.codeguru.com as well.
Happy Coding !!
-Mahesh Shimpi
Ideas multiply by sharing!!
|
|
|
|
|
thx a lot, Mahesh!
seems i got no choice now, ...
but the coding process is really wonderful!
|
|
|
|
|
hi
i like to use combobox for storing items in vc++. but the problem is it
can't store more than 32,735 items because of integer datatype limit is 32735. But in MFC int lenght is around -2 crores to +2crores. even it accepts only 32735 items only.why? please explain how can i add items into combobox more than 32,735. how can i overcome this limit
please help about this
thank you
from
venu
|
|
|
|
|
the comboBox has not the limit 32735,the limit is (int)
|
|
|
|
|
Hi!
I have a C++ class with a callback function. Now I wanna use this class in .NET enviroment. So according the guide, i wrap it in a managed class.
But the problem is the callback. The unmanaged class must have an ability to callback the managed class. How can the callback function in unmanaged class get the pointer of the delegate(or something like that) of the managed class?
any suggestion?
|
|
|
|
|
I am not sure about this, but it may have something to do with delegates. Read about them in the documentation.
Best regards,
Alexandru Savescu
|
|
|
|
|
Hi,
I have an application developed using VC++ & MFC.Here i
need to display Japanese strings.
I do m_staticname.SetWindowText(the_name);
where m_staticname is member of type CStatic.
This doesn't work.
But GetDlgItem(IDC_NAME)->SetWindowText(the_name); works.
Could anyone please tell me how to make this
m_staticname.SetWindowText(the_name);
statement to work.
Regards
Neha
|
|
|
|
|
Delete your m_staticname declaration.
Then open Class Wizard.
Goto the member variables tab.
Double click on the IDC_NAME id.
Create a member variable named m_staticname of type CStatic that is associated with the IDC_NAME resource.
Roger Stewart
"I Owe, I Owe, it's off to work I go..."
|
|
|
|
|
I have the folowing piece of code
<br />
typedef struct _HEAP_STRUCT<br />
{<br />
struct _HEAP_STRUCT *next;<br />
struct _HEAP_STRUCT *prev;<br />
}HEAP_STRUCT, *PHEAP_STRUCT;<br />
<br />
<br />
PHEAP_STRUCT pStruct;<br />
<br />
<br />
<br />
char HeapSpace[4096];<br />
<br />
void Init(void)<br />
{<br />
<br />
pStruct->next = (PHEAP_STRUCT)HeapSpace[4096];
pStruct->prev = (PHEAP_STRUCT)HeapSpace[0];<br />
<br />
<br />
<br />
<br />
};<br />
Every time it comes to the init procedure, it gives me the access violation. Even i attempt to put
pStruct->next = NULL;<br />
it still give me access violation.
Does anyone have any idea?
Thanks
|
|
|
|
|
That is because pStruct is declared as a PHEAP_STRUCT object which is actually a pointer to a _HEAP_STRUCT object. This means that no memory has been allocated to the structure itself, just the pointer. Therefore when you try to dereference the next parameter, you will get an access violation. In order to fix this you can do a number of things:
1) Declare pStruct as a HEAP_STRUCT object instead, then it will not be a pointer and memory will be allocated for this object on the stack.
<br />
HEAP_STRUCT struct;<br />
void Init()<br />
{<br />
struct.next = HeapSpace[4095];<br />
struct.prev = HeapSpace[0];<br />
}<br />
2) You can dynamically alloate memory for your pointer to your struct inside of your Init function and that will associate memory with your object.
<br />
PHEAP_STRUCT pStruct;<br />
void Init()<br />
{<br />
pStruct = new HEAP_STRUCT;<br />
pStruct->next = HeapSpace[4095];<br />
pStruct->prev = HeapSpace[0];<br />
}<br />
Finally, I do not know if this was a typo, but you assigned the HeapSpace[4096] element to the next variable. However for the array that you declared the 4095 index is the last element in the array that you delcared.
Good Luck
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!
|
|
|
|
|
Excellent answer! It explains everything !!!
Thank you very much!!!! I really appreciate it!!!
|
|
|
|
|
Hello,
In CMyClass I have those members:
<br />
private:<br />
MSXML2::IXMLDOMDocumentPtr m_pxmlDoc;<br />
MSXML2::IXMLDOMNodeListPtr m_pxmlLlistaNodes;<br />
MSXML2::IXMLDOMNodePtr m_pxmlNode;<br />
I allocate memory for the document in this way:
<br />
this->m_pxmlDoc = new MSXML2::IXMLDOMDocumentPtr("MSXML2.DOMDocument.4.0");<br />
and in my ~CMyClass (the destructor of my class) I try to deallocate it using:
<br />
this->m_pxmlDoc->Release();<br />
delete this->m_pxmlDoc;
Could you give me an advice on how to deallocate that memory?
thank you in advance...
|
|
|
|
|
I see a few things that might help you out:
1) When you call release on your document, there is no need to call delete. That is because internally when the reference count to your document goes to zero, the COM object will automatically destroy itself. That is probably why you are getting the memory exception when you try to delete the object.
That brings me to my next point,
2) Is there a reason that you are not allocating the document pointer this way:
<br />
IXMLDOMDocumentPtr pDoc;<br />
HRESULT hr = pDoc.CreateInstance(MSXML::CLSID_DOMDocument);<br />
if (FAILED(hr))<br />
{<br />
...<br />
}<br />
AFAIK you are not supposed to use new to allocate COM objects, unless these smart pointers overload the new operator to call CoCreateObject. And even if they do overload the new operator, for the sake of clarity in your code I would recommend the method that I showed you above. Although you may need to find the correct CLSID that matches the version that you are trying to create.
Good Luck
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!
|
|
|
|
|
That's because I didn't know nothing about this other method...
I'll try it...
And thank you very much!
|
|
|
|
|
Hello,
I have two dialog windows with edit boxes in C++ MFC (Multiple document interface). Through menu bar in my GUI interface I am opening one dialog window and entering set of data in edit boxes and closing that window to open another dialog box to enter another set of values in edit boxes. After closing second dialog box, there is Menu item called "execute" to run my code routine by using the values entered in previous edit boxes in Dialog windows. And the result should be displayed in Listbox control. Can somebody help me out with code example. I am a beginner and trying to learn for one of my assignment. I apprecaite any help.
|
|
|
|
|
How much have you alreaady done ? Where are you stuck ?
Christian
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
|
|
|
|
|
Here are the steps I am trying to do.
1) I am opening 'Dialog A" which contains edit boxes from Menu item "Menu A". I am entering data in edit boxes and I am closing it. It doesn't have any buttons.
2) I am opeing "Dialog B" by using Menu Item "Menu B" to enter another set of data in edit boxes. Similarly no buttons on this dialog and I am closing this also after entering data.
3) I have to caputure the data entered in "Dialog A" and "Dialog B" edit boxes. When I click on another Menu Item called "execute" ,by using parameter values entered in "Dialog A" and "Dialog B" to perform my logic and the result should be diaplyed in Third Dialog window Called "Dialog C" which has List box Control. The "Diolog C" has only list box Control.
I am having problem in getting the data entered in "Dialog A" and "Dialog B" in a function which is called upon on Clicking 'Execute" Menu Item.
I hope this clarifies my problem.
Thanks.
|
|
|
|
|
The existence of the three dialogs sounds like bad design, although that might just be because I have no idea what they are for, or what other potential paths of execution exist.
When your dialog is closed, any data in edit boxes, etc. that you had in those dialogs is gone. There fore you must create variables of type CString or int, or whatever, and stuff your values into those in your dialog boxes closing method. When your dialog box instance goes out of scope ( i.e. the function that created it ends ) then it's contents are deleted, so you need to have a member variable of your Mainframe, or whatever class handles the menu items, and store the values from the dialog box there within the function that created the dialog. Since you have three menu items, you need to initialise these values to some known, but impossible to enter, value, so that you can check if someone chooses menu item 3 before entering data into the first two menu items.
Then when you call dialog three, you can make the default constructor private ( so it cannot be called ) and create instead a constructor which takes the values it needs, and pass them in from your member variables.
Christian
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
|
|
|
|
|
Hello,
I've created a .ico file contains the 16x16 256 color icon for tray icon and load the icon with LoadImage. When I load the icon from Windows ME/XP it looks fine, however, it doesn't look good in Win 98/2K. The color of the tray icon has changed. Do you have any idea what's going on?
Thanks,
Hiusing
|
|
|
|
|
Windows 2000 and windows 98 only support 16 bit color icons in the tray.
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!
|
|
|
|