|
Hi all.
I have a listview handle and some item index. I want to select it via windows api.
Can someone help me?
Thx in advance.
Best Regards,
Marco Alves.
|
|
|
|
|
I have an application whose shortcut is placed on the desktop. Now whenever i double-click that icon, I want to get the information for that icon like Icon name, Icon target path, Icon working directory. The reason behind this is from one of the functionality the working directory changes for the application. So through Windows API or in C#/C++ I want to change the working directory for the icon which is double-clicked.
Plz guide me soon and at the earliest, if possible.
Regards.
Chilly
|
|
|
|
|
you can resolve an icon information using the IShellLink interface methods: Resolve(), GetPath(), GetDescription() etc. For this u need to pass the sortcut path. But for resolving it on icon click, u may need to write a mouse hook dll or a shell extension.
cheers..milton kb.
|
|
|
|
|
Actually when we use dll's then we use #import key word rather than we use #include key word, so what ll be the difference between them.
|
|
|
|
|
|
Hello Dear Friends,
I face a strange problem with GroupBox Controls in .Net 2
This is a story:
I made a custom control inherited from GroubBox Control. I've put some other ocntrols in this new control and I've added them by this statement in my new control: this->Controls->Add(some .NET Control).
This is a problem:
When I set Anchors or Docks to my controls it dosn't work. BTW It seems that the anchored to left and top and I can't change them noway. (The parent control i.e. Custom GroupBox works perfect and change it's size correctly but it's childrens no!)
Every hint in appriciated.
Wish you luck.
Mamad
|
|
|
|
|
I don't understand why, but it's writing garbage instead of the text. When i use CFile.write, it's working correctly. anyone knows why.
also is there a tricks to add null at the end of a string? i tried this:
iEnd = strlen(cInfo);
cInfo[iEnd -1] = '\0';
but it's never written into the file, so i'm assuming it's not in the string?
|
|
|
|
|
I defined an enum like that:
public enum class FontQuality : __int32
{
Default = DEFAULT_QUALITY,
Draft = DRAFT_QUALITY,
Proof = PROOF_QUALITY,
NonAntiAliased = NONANTIALIASED_QUALITY,
AntiAliased = ANTIALIASED_QUALITY,
ClearType = CLEARTYPE_QUALITY,
ClearTypeNatural = CLEARTYPE_NATURAL_QUALITY
};
Now I'm using it in C# library and the compiler warns me that it is not CLS compliant...
Why is that? (and how to fix it?!)
When I define a similar enum in C# I have no CLS compliance issue...
|
|
|
|
|
I have VS2005
Experimenting with header file is quite difficult because most of the time I do so VS2005 eat up 100% CPU and, slowly, all the memory as well (1GB, 2GB, 3GB, ... piou...... (reboot button))
Now I have been told that header file should speed up my compilation (which is rather slow even though the Managed C++ project is small)
Because I include <windows.h> in many headers (needed to define some enum from Windows constants) I though: OK: let's #include <windows.h> in stdafx.h.
But I have a doubt.. does it makes any sense to include a precompiled header in other headers?
|
|
|
|
|
Hi, I have a native abstract base class from which a number of child classes inherit from. The abstract base class has a pure virtual function that is overridden in each of the child classes.
My problem is this, how can i write managed wrapper classes for the base class and child classes whilst maintaining the ability to declare a base class pointer and to later instantiate a child class with it?
I cannot instantiate the base class because it a pure base class (I would not want to anyway) and if I wrap each child class individually then I will no longer have runtime polmorphism.
Am I being thick or is it not possible? Any advice greatly appreciated. Thanks
zenzero
|
|
|
|
|
Declare a class with a base class pointer and a constructor having a base class pointer parameter ... likes auto_ptr
|
|
|
|
|
Initial Clarification: I need different memory stack (where addresses are stored), Not a stack container as in similar to a linked list container.
I need to create a new memory stack when different command line parametrers are used. It is to simulate a buffer overflow problem and our assignment specs say when a different user is specified, a different stack is created so a different attack is needed(a different amount of overflowing data).
Quote from ass specs
"It is required that each of usernames (Alice, Bob, or Chris) is associated with a different memory stack. You need to provide an attack for each of them. As a result, three buffer overrun instances and their associated attacks should be provided in your report. It is up to you for the coding approach."
I can call my program :
myProg.exe Alice
myProg.exe Bob
What I have done is implement each user into a different function. This doesnt force me to use a different attack for each user (same attack works for each user.)
I then put some initialised local variables inside bob() function, to make it different to the Alice() function. This didnt change what I wanted either.
I also created a few dummy functions which just passed the control to then next function to eventually start the Bob function. but this didnt make it any different from just calling bob straight out. (if that makes any sense)
I read this (and many other) websites to try and understand how variables and functions are alocated to the stack
http://users.actcom.co.il/~choo/lupg/tutorials/unix-memory/unix-memory.html#c_stack
But I obviously still dont understand how addresses are allocated to the stack to make it different for different command line parameters.
Ive spent a day and a half trying to solve this problem, the rest of my code does what I want
Can someone please clarify this or give me an example of how to create a different stack for different parameters.
Thanks in advance
|
|
|
|
|
Am I dreaming, or is there a way to add a labels to a document and print the document, so you get little squares of text all over the page?
Thanks
|
|
|
|
|
Is this question from a managed perspective? Or do you want to know how to do this in native C++? If the latter this is the wrong forum. If the former, it may be better to ask this in the C# or .NET forum, since your question is not C++/CLI specific, and there are more people answering such questions on those forums.
|
|
|
|
|
Hi,
I have created a program for calculating the Mandelbrot set and other fractals. I have two versions of the program, one where the fractal class is native and another where it is managed. This class contains the main iterative loop for determining whether a point is in the fractal or not; for example, Z = Z^2 + C for the Mandelbrot set. The front end of both versions is managed. The iterative loop is written in straight C++ with no assembler.
I created a test scenario and used a stopwatch to time how long each version of the code took to complete. I found that the native version took consistantly 17.5 seconds +- 0.5 seconds. However, the managed version is inconsistant in the amount of time it takes. It can take 21, 28, 45, or 47 seconds to complete. Why is this? The only thing I can think of is that it is executing the loop in main memory or level 2 cache instead of level 1 cache.
In a second, more intensive, scenario the native version takes 1min 38.5secs and the managed version takes 5mins 11.5sec - this is horrendous!
Does anybody have an ideas? Is it possible to 'fix' the managed version so that it has performance equal to the native version? Any help would be greatly appreciated! Thanks.
zenzero
|
|
|
|
|
The managed version, when run, always needs to compile your code before running it. This is the main reason for the delays.
I wrote a very complex piece of image processing code in C#, and moved it to C++. The C# version took 5 minutes, the C++ port took days. I had to rethink my approach, the rewritten c++ version takes 4 minutes. The point is, languages are different and care needs to be taken to do reasonable bench tests. One core thing is to make sure the actual application takes long enough for the initial compilation step not to be an issue. To avoid this problem, simply write the code to run twice from a subroutine, with a keypress inbetween. The second time, it will have been precompiled.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi Christian, Thanks for your reply. I am not anti managed code, I think my subject title has given the wrong impression.
My program is quite sophisticated, so I am able to load and start my test scenario after the program has finished loading/ compiling. I can restart/ rerun my test scenario at will.
I did some investigating with a profiler and I found that with the managed version a disproportionate amount of time is spent in periodicity checking. I removed the call to the periodicity checking and this did improve the times, but they were still inconsistant (but not as bad before). So the periodicity checking is exacerbating the problem, but is not the cause.
I did some more timings and I found that the time taken is more consistant (+- 2secs) between test runs within a particular load of the program. The larger variations occur between 'loads' of the program.
Am I right in thinking that all types (even basic types, such as int and double) are on the managed heap in managed code as opposed to the stack with native code? Could this be the cause of the problem?
I did another test run this time with solid guessing turned off (solid guessing reduces the number of times the main iterative loop is run), the native version took 2mins 6secs and the managed version took 6mins 49secs.
Here is the code for the main iterative loop, where Cx and Cy are the point coordinates and TestCount, MaxIters and Bailout have previously been declared and initialised:
<br />
double Zx2;<br />
double Zy2;<br />
<br />
for(TestCount = 0; TestCount < MaxIters; TestCount++)<br />
{<br />
Zx2 = Zx * Zx;<br />
Zy2 = Zy * Zy;<br />
<br />
if(Zx2 + Zy2 > Bailout)<br />
{ break; }<br />
<br />
Zy = 2.0 * Zx * Zy + Cy;<br />
Zx = Zx2 - Zy2 + Cx;<br />
}<br />
In my test scenario it runs for 100,000 iterations per pixel on a 640x480 image, so that is a maximum of 30,720,000,000 iterations (assuming no guessing). Any small inefficiency caused by the managed code will be greatly magnified by the large number of iterations. My code is straight forward, I do not see how a different approach could be anymore efficient.
If this is a shortcoming of managed code then ok, but I was wondering if I was doing anything wrong? Thanks!
zenzero
|
|
|
|
|
Obviously, native code is going to be faster than managed code (in most scenarios). But the differences you quote definitely seem odd. Managed code, after the JIT compilation, should technically be as fast as equivalent native code. But, it again depends on how you've written it. It's hard to say why your managed code is performing so bad without seeing it. Again, taking the exact same C++ code and compiling as /clr would result in MSIL that when JITed would (supposedly) run as fast as its native equivalent, though you may find minor performance differences.
|
|
|
|
|
Hi Nish,
Thanks for your thoughts. Actually both the 'native' and managed versions are compiled with the /clr:pure option, so both are compiled to MSIL. The class structure of the native version is like this:
<br />
class Fractal<br />
{<br />
<br />
public:<br />
virtual int DwellTest(int) = 0;<br />
};<br />
<br />
<br />
class Mandelbrot : public Fractal<br />
{<br />
<br />
public:<br />
int DwellTest(int, int);<br />
};<br />
<br />
<br />
int Mandelbrot::DwellTest(int X, int Y)<br />
{<br />
InitParams(X, Y);<br />
<br />
double Zx2;<br />
double Zy2;<br />
<br />
for(TestCount = 0; TestCount < MaxIters; TestCount++)<br />
{<br />
Zx2 = Zx * Zx;<br />
Zy2 = Zy * Zy;<br />
<br />
if(Zx2 + Zy2 > Bailout)<br />
{ break; }<br />
<br />
Zy = 2.0 * Zx * Zy + Cy;<br />
Zx = Zx2 - Zy2 + Cx;<br />
}<br />
<br />
UpdateState(X, Y);<br />
return TestCount;<br />
}<br />
For the managed version I changed how the classes were declared.
<br />
public ref class Fractal abstract<br />
{<br />
<br />
public:<br />
virtual int DwellTest(int, int) = 0;<br />
};<br />
<br />
<br />
public ref class Mandelbrot : public Fractal<br />
{<br />
<br />
public: <br />
virtual int DwellTest(int, int) override;<br />
};<br />
That probably doesn't help very much!
The reason I was trying to do this is because I wanted to compile it has a class library so that I can use it Mono and create a new platform independent front-end in C# and Mono's implementation of Forms. Unfortunately Mono does not yet support C++/CLI and Micosoft's Windows.Forms is not portable. My other possible solution to the problem was to wrap the native code in C++/CLI but I do not know how to do that for an abstract base class, hence my other question further up
I will probably wait for the Mono team to support C++/CLI
|
|
|
|
|
is it possible to call a native C++ Method from a Managed(?) C++ DLL and pass a std::wstring by ref?
I have a native C++ DLL. This has a static function
<br />
IServer * CreateServer();<br />
I created a Managed C++ DLL, imported the native DLL and now trying to make it work.
<br />
....<br />
[DllImport("DoubleFindDll.dll")]<br />
extern "C" IServer * CreateServer();<br />
<br />
....<br />
IServer srv = CreateServer();<br />
srv->startUp();<br />
std::wstring some_string;<br />
srv->FooBar(some_string);
<br />
FooBar is defined as:
<br />
virtual void FooBar(std::wstring & str) = 0;<br />
and the string is modified inside the method.
Im using VS2005.
Thank you for any hint.
|
|
|
|
|
I need to get a string from an editbox and write it to a binari file. The only problem i'm getting is that my string ends with 0D 0A instead of 00 and it's very important that it ends with 00. Is ther a way to do that easily.
I'm using Cfile and CString only because that the only way i found to write japanese correctly to a binary file and i know it's looks ugly in a managed project.
Here is the importants parts of the code
CFile fVampFile;
char * cInfo = "";
int iEnd;
fVampFile.Open(csFilename,CFile::modeWrite | CFile::shareExclusive | CFile::modeCreate | CFile::typeBinary )
cInfo = (char*)Marshal::StringToHGlobalAnsi(eSpeech->Text).ToPointer();
iEnd = strlen(cInfo);
fVampFile.Write(cInfo,iEnd);
|
|
|
|
|
Hi, I'd need some help with my commandline application.
Its basically a contact list application which allows user to choose to add two types of contacts (club and client).
I wrote the classes for these two. So when the choice is made, a function ADD() is invoked which creates this arrays of type club or client.
The problem is as these object arrays are created within the ADD() function, they have only a local scope so I tried referencing its values so that in the end, the main() function can have have access to them.
But unfortunately the message from the compiler is "referencing an array...."
Is it possible to reference an array so that its scope becomes virtualy global?
If not, what other ways can a variable object within a function be accessed easily by other functions?
|
|
|
|
|
Is this a C++/CLI question, or just C++.
Either way, in this forum or the C++ forum, it sounds like you need to post your code. You can return anything from a method, you can't declare anything in a method and give it scope outside the method without returning it. Returning a pointer makes the most sense ( saves a copy being made ).
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
|
|
|
|
|
Hi again...The code is below and i hope it helps clarify my enquiry.I'm new to C++ and all help and suggestions are much appreciated.
*******************code for contact list********************
#include <cstdlib>
#include <iostream>
using namespace std;
class BasicAd{
protected:
string name;
string home_address;
public:
void BasicAd::setValues(string n, string h){
name = n;
home_address = h;
};
void BasicAd::getValues(){
cout<<"name : "<<name<<endl;
cout<<"home address="" :="" "<<home_address<<endl;
};
};=""
class="" clubdir:="" public="" basicad{
private:
string="" member_name;
int="" date_joined;
public:
void="" clubdir::setvalues(string="" n,="" string="" h,="" nm,="" int="" d){
name="n;
home_address" =="" h;
member_name="nm;
date_joined" d;
};
void="" clubdir::getvalues(){
cout<<"name:="" "="" <<name<<endl;
cout<<"home="" "<<home_address<<endl;
cout<<"member="" name:="" "<<member_name<<endl;
cout<<"date="" joined:="" "<<date_joined<<endl<<endl;
};
};="" clientdir:="" client_name;
string="" business_address;
public:
void="" clientdir::setvalues(string="" ha,="" cn,="" ba){
name="n;
home_address" ha;
client_name="cn;
business_address" ba;
};=""
void="" clientdir::getvalues(){
cout<<"\nname:="" "<<home_address<<endl;
cout<<"client="" "<<client_name<<endl;
cout<<"business="" address:="" "<<business_address<<endl<<endl;
};=""
};
void="" add(clubdir&="" [],="" clientdir&="" int&="" size);
void="" edit();
void="" delete();
void="" getoption();
void="" display();
int="" main()
{=""
int&="" sizze;=""
clubdir&="" clubb[size];
clientdir&="" clientt[size];=""
cout<<"....welcome="" to="" the="" contact="" database...."<<endl;
cout<<"-------------------------------------------------"<<endl<<endl;
getoption();
system("pause");
return="" exit_success;
}
void="" add(){=""
string="" name;
string="" ha;
string="" mn;
string="" cn;
string="" ba;
int="" dj;
int="" choice;
clubdir="" club[size];
clientdir="" client[size];=""
cout<<"please="" select="" one="" of="" choices="" perform="" its="" task:="" \nclubdir="" [1]\tclientdir="" [2]:="" ";
cin="">>choice;
if(choice==1){
cout<<"\nEnter number of items for clubDir: ";
cin>>size;
for(int i=0; i<size; i++){
cout<<"\nenter="" values="" of="" clubdir="" "="" <<="" (i+1)="" ":\nname:";
cin="">>name;
cout<<"home address: ";
cin>>ha;
cout<<"member name: ";
cin>>mn;
cout<<"date joined:";
cin>>dj;
cout<<"\n";
club[i].setValues(name, ha, mn, dj);
};
cout<<"\nThe Contact Details addded....";
}
else if(choice==2){
cout<<"\nEnter number of items for clientDir: ";
cin>>size;
for(int i=0; i<size; i++){
cout<<"\nenter="" values="" of="" client="" "="" <<="" (i+1)="" ":\nname:";
cin="">>name;
cout<<"home address: ";
cin>>ha;
cout<<"client name: ";
cin>>cn;
cout<<"business address:";
cin>>ba;
cout<<"\n";
client[i].setValues(name, ha, cn, ba);
};
cout<<"\nThe Contact Details addded....";
};
}; //end of ADD()
void EDIT(){
};
void DELETE(){
};
void DISPLAY(){
};
void getOption(){
int option;
cout<<"Select one of the following options :\nADD - [1] \tEDIT - [2]\t DELETE - [3]: ";
cin>>option;
cout<
|
|
|
|
|
There is an exception caught during loading the Form, but the Form will be loaded no matter what. I want to display that exception Message in front of the Form once the Form is loaded.
If I use message box to display the exception Message inside the Form_load function, the Exception message box is behinde the Form. How can I make it displayed in front of the Form?
|
|
|
|
|