|
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!
|
|
|
|
|
Hello folks,
I have a basic question in C programming:
BOOL a, b, c;
if(a && b, c)
{
/*do this*/
}
else
{
/*do that*/
}
What does the "," in the if condition signify?!?
Thanks!!
|
|
|
|
|
The comma operator performs the operation to it's left, and returns the result of the operation to it's right.
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
|
|
|
|
|
Does this mean that if, in my example, a and b are TRUE, then the comma operator will set the value of c to TRUE?
Thanks!!
|
|
|
|
|
Um.... no. It means if you had this:
if (a *= 7, a%2 == 0)
{
}
then a will be multiplied by 7, and if a if an even number ( a mod 2 = 0 ) then the if statement will succeed. Either way, a will be multiplied by 7.
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
|
|
|
|
|
The comma operator evaluates the left side, then the right side, and returns the value of the right side. So the value of the expression a && b, c is c .
--Mike--
"I'd rather you just give me a fish today, because even if you teach me how to fish, I won't do it. I'm lazy." -- Nish
Just released - 1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
|
The what is already answered.
The why is: the left side expression is
evaluated purely for its side effect.
Your code must be a paraphrase that's omitting
details which would explain the intent. As it
stands there is no reason for the schmoo, but
the structure is a common one.
In this case "a" was probably, without side
effect, an expression that drove "b" to be
evaluated or not (the && operator evaluates
the right side only if the left side is true,
a conditional short-circuit. That's why the
statement "a && b;" is often used as shorthand
for "if (a) b;")
The author just wanted to scrunch up his code
and place what normally would have been a
preceding conditional statement "if (a) b;"
smack dab in the next conditional
"if (c) blark; else snarf;"
i.e.
"if (a) b; if (c) d; else e;" <-->
"a && b; if (c) d; else e;" <-->
"if (a && b, c) d; else e;"
|
|
|
|
|
What I want to do is make it so that when the user wants to open a file it only shows files of that specific type, that type is .TX0, .TX1, .TX2, ... , .TX9.
Here's my code for the Open Dialog:
<br />
CFileDialog fileDlg(TRUE, NULL, NULL,<br />
OFN_OVERWRITEPROMPT | OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST,<br />
"My Files (*.TX*)|*.TX*|All Files (*.*)|*.*|",<br />
NULL );<br />
I have it so it will show all files of type .TX* but that means .txt files will show up as well as my file types. Is there a way to not show .txt files but still show my files?
There's always one more bug.
|
|
|
|
|
use
"My Files (*.TX*)|*.TX0;*.TX1;*.TX2;*.TX3;*.TX4;*.TX5;*.TX6;*.TX7;*.TX8;*.TX9;|All Files (*.*)|*.*|" <br />
<br />
<div style="padding-top: 12pt; float: left"><br />
<font color="blue">Shog<font color="green"><sup>9</sup></font></font><br />
------</div><br />
<div align="right" style="padding-right: 1em; margin-bottom: -2em; font-size: 8pt; font-family: "Sylfaen"; color: rgba(64, 103, 119, 1)" title="Social Distortion - "Down Here (W/ The Rest Of Us)"">No one's immune now, from a world of problems <br />
No one's exempt now, from a world of pain <br />
That's the way that it goes <br />
when you're down here with the rest of us...</div>
|
|
|
|
|
Thx a lot
There's always one more bug.
|
|
|
|
|
If process A creates shared memory via CreateFileMapping and then process B opens shared memory via OpenFileMapping does the shared memory become invalid when process A exits? If process B stays running and now process C opens shared memory via OpenFileMapping will the shared memory still be valid?
Todd Smith
|
|
|
|