|
Hi! Everybody,
I am new to programming and this is my first post here. I have problem with assigning a string which is returned by the active component to my edit control box. I will appreciate any hint if possible.
I have created a dialog based MFC standard application and I am using a button to simulate the problem by clicking on the button, but without any progress. This is the description of what I have done:
- Created a C++ dialog based MFC application
- inserted an ActiveX component and created a member variable called “m_Active“
- inserted an edit control and created a member variable called “m_Edit”
- inserted a button and crated a member variable called ”m_Button”
void CTestDlg::OnBnClickedButton()
{
// TODO: Add your control notification handler code here
m_Active.mConnect(0);
m_Active.mListening(1,2000);
m_Active.mStartServers(1,2001,2002,2003);
m_Active.mStreamVideo(1);
m_Active.mStreamAudio(1);
m_Edit.SetString(mGetLocalHostName);
}
……………………………………………………………………………………………………………………
Every thing works fine untill the last line
M_Edit.SetString(mGetLocalHostName);
I have to add that “mGetLocalHostName” forces the ActiveX component to return the string wich I am intending to have in the Edit control.
I hope I have been able to describe the problem I have. And I appriciate any kind of help.
|
|
|
|
|
Hamid intact wrote: inserted an edit control and created a member variable called “m_Edit”
What kind of a member variable is m_Edit? Since you are calling SetString() upon that member variable, I am assuming it is a COleVariant . Try using a control variable instead of it and call SetWindowText(mGetLocalHostName) on it instead.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Hi Rajesh!
Thank you for showing interest in this problem.
I did the changes you suggested.
“m_Edit” is a control variable member now. And after changing the code to
void CTestDlg::OnBnClickedButton()
{
// TODO: Add your control notification handler code here
m_Active.mConnect(0);
m_Active.mListening(1,2000);
m_Active.mStartServers(1,2001,2002,2003);
m_Active.mStreamVideo(1);
m_Active.mStreamAudio(1);
m_Edit. SetWindowTextW(m_server.mGetLocalHostName);
}
I get an error which says:
error C3867: 'CTestserver::mGetLocalHostName': function call missing argument list; use '&CTestserver::mGetLocalHostName' to create a pointer to member
Could you please lead me to a solution?
With thanks in advance.
|
|
|
|
|
What is a mGetLocalHostName ?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi David!
"mGetLocalHostName" returns a string containing the domain name and service of the local socket endpoint.
|
|
|
|
|
Hamid intact wrote: "mGetLocalHostName" returns a string containing the domain name and service of the local socket endpoint.
Then why are you doing like this: m_Edit. SetWindowTextW(m_server.mGetLocalHostName); ? Won't m_Edit.SetWindowTextW(mGetLocalHostName) suffice? Just try m_Edit.SetWindowTextW(_T("Hello world")); . Is that working? If yes, the problem is not with SetWindowTextW .
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Hi Rajesh!
m_Edit.SetWindowTextW(mGetLocalHostName) end with an error (undeclared identifier)
m_Edit.SetWindowTextW(_T("Hello world")); works fine
I have changed the last line as
m_ip. SetWindowTextW(m_server.mGetLocalHostName());
and I get the returned string from ActiveX component in the Edit kontroll.
It works fine now. Thank you. I could not have been succseded without the help from Krmed and you.
|
|
|
|
|
You're welcome, Hamid. I'm glad I could be of some help.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
It would appear that you are trying to call a method (mGetLocalHostName) in your ActiveX, but are just passing the method name - you're missing the call and arguments.
Perhaps it should be:
m_Edit. SetWindowTextW(m_server.mGetLocalHostName(arguments_go_here if any));
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
Hi Krmed!
You are right. I have been missing () för the argument.
m_ip. SetWindowTextW(m_server.mGetLocalHostName());
It works fine now. Thank you. I could not have been succseded without the help from Rajesh and you.
|
|
|
|
|
Hello, i know this will sound kind of a noob question, but i cannot find any support on this anywhere.
I made a project in visual studio c++ (non-managed) and every time I need to change the icons, the executable will get a random icon (i guess it's the first icon i add at the resource editor.)
Is there any way to set the icon i want to the exe file in the editor without those time consuming workarounds?
best regards ![Smile | :)](https://codeproject.global.ssl.fastly.net/script/Forums/Images/smiley_smile.gif)
|
|
|
|
|
marcio kovags wrote: i guess it's the first icon i add at the resource editor
Correct.
marcio kovags wrote: Is there any way to set the icon i want to the exe file in the editor without those time consuming workarounds?
Time-consuming workarounds? How about just leaving one icon (with an ID of 1)
as the app's icon (used by the system shell) and add any other icons you need to the
resources?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Dear all,
I have,
CImageList ImgList1;
CImageList ImgList2;
CImageList MasterImgList;
I have added several "CBitMap" objects to the "ImgList1" and "ImgList2" using CImageList::Add( CBitmap* pbmImage, COLORREF crMask ) method.
Now I would Like to Merge "ImgList1" and "ImgList2" to the "MasterImgList".
That is after merging, "MasterImgList" contains both the contents of "ImgList1" and ImgList2".
Please help me..
Thanks in Advance
George K Jolly
|
|
|
|
|
georgekjolly wrote: Now I would Like to Merge "ImgList1" and "ImgList2" to the "MasterImgList".
why CImageList:: ( Add, Copy, Remove, Replace) member functions can't be used to achieve the image list merge.
|
|
|
|
|
Try using CImageList::GetImageInfo() to get the HBITMAP handles for
the bitmap and mask of the imagelist you want to add.
With those handles, you can make the CBitmap objects to use in a
call to CImageList::Add().
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mark,
Thank you for your reply.
You mean, extracting BitMap from CImageList and adding it to the Master Image List..
But will it make any overhead ?
Or Can we achieve the merging of ImageLists using some other methods like Copy..
Thanks
George K Jolly
|
|
|
|
|
It wouldn't really be "extracting" the bitmaps from the imagelist since
bitmap(s) are part of an image list already. What I described is more of a
copy and add.
Sure there's overhead - there's overhead doing anything. Whether it's
detrimental to the performance of your app or not depends on how often you do it.
e.g. Thousands of times a second...You could do better managing bitmap memory yourself
The most overhead probably involves creating a new bitmap, copying the original bitmap,
then the copy from the second imagelist bitmap. It's still more efficient than adding one
image at a time, which is what imagelists are best suited for (in their available functionality).
I don't know of a copy operation that copies one imagelist to another.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Is anybody knows how to run MS ACCESS from dialog?
Thanks.
|
|
|
|
|
Do you just want to run MS Access or you want to do interact with an MS Access database? Have a look at ShellExecute() API to run MS Access and CDatabase class to interact with a datbase (if you're using MFC).
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Thank you. ShellExecute() API to run MS Access is quite enough for me. Now I need to understand how to send password into MS Access with help of ShellExecute().
|
|
|
|
|
It will only work if Access accepts command-line arguments.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Let's say I have the following:
---- Start .lib ----
class A
{
...
};
class B
{
public:
B();
int Func3();
static int Func1();
static int Func2();
};
class C
{
public:
static int Func1();
};
---- End .lib ----
---- Start .exe ----
...
int main()
{
C::Func1();
}
---- End .exe ----
This is the simplest example of the problem. C::Func1() calls B::Func1(). B::Func1() executes code but DOES NOT instantiate class A, call B::Func2(), or instantiate any instance of B(). B::Func2() instantiates an instance of A and B. I have all Visual Studio 2008 compiler optimizations turned on that I can find (/GL, /Ox, /GF, /OPT:REF, /OPT:ICF, /ltcg).
Yet, when using a static disassembler, I can clearly see that just because I reference one static function in a class (B::Func1()), even though the other static functions in the class are not used (B::Func2()), that code is included, which in turn makes any classes they use get included (e.g. class A), and then those functions include classes they use.... The end result is an unnecessarily _huge_ executable. As I said, this is just a simple example.
As far as I can tell, this is a "bug" that has been in VS since VS.NET. The only thing I can think of to possibly solve this is to create a class for each and every static function in the code...but that will likely take weeks to complete. Any better suggestions other than that?
And it would be really nice if anyone here could confirm that this is actually a bug in VS.
modified on Saturday, March 15, 2008 12:41 PM
|
|
|
|
|
What do you want to achieve? For calling the static functions inside a class, it need not "instantiate" an object.
----------------------------
286? WOWW!
|
|
|
|
|
What I want to achieve is a smaller executable. And my point is that static functions I'm not referencing ANYWHERE are being included in the final executable for no good reason other than they have the 'static' keyword.
I've noticed that not all functions are being included - some are getting optimized away - but not all of them.
|
|
|
|
|
I'm hearing this for the first time!? My guess is that no matter you make a function static or not, it will be included in the exe. If you want to avoid those functions, group all those functions and put them into a dll. If anything's need , you may load the dll at run time and call the functions. That's the only way! If you are damn sure about your concept, provide me a link here.
----------------------------
286? WOWW!
|
|
|
|