|
if number is only one digit then its simple.
char c = '3';
// char => int
int i = c - '0';
// int => char
c = '0' + i;
|
|
|
|
|
Any source code?
please contact:
max_xiayi@hotmail.com
|
|
|
|
|
Friends,
I've created an application in VC++ 6.0. There is a dialog in it on which i dropped various controls and associate class with that dialog.
Now, i am creating another project in VC++ 6.0. I want to use the same dialog template and its class in this project.
Please tell me how can i "import" dialog from one project to another. Obviously i can reuse class header and cpp, but how can i import dialog template ??
|
|
|
|
|
If you mean the dialog resource, do it this way. Open the old project and simply copy the dialog resource to clipboard. Then, open the new project and paste it into its resource script in the resource view window. Should work.
|
|
|
|
|
unfortunately this is not working in case of different projects. If we have two dialogs in same project then we can copy-paste resources.
|
|
|
|
|
|
Hi All, my CListCtrl's DeleteAllItems() is not working. Although it is returning me non-zero and according to MSDN it returns non-zero when it succeeds but it is not erasing the contents of List control. Any help/advice?
Regards,
Still Alone in this beautiful world
My Articles
|
|
|
|
|
Sorry, I have done it. It was another fault.
Still Alone in this beautiful world
My Articles
|
|
|
|
|
you can send the message LB_RESETCONTENT to the list box
|
|
|
|
|
How to handle the modem connection on the line?
For example i want to call a connection dialog, where i choose the provider of internet (simple connection dialog in windows - how to call it?, i see it when i open the Internet Explorer - it offers me to get online, i want to call such window). Then i want to know - if i connected, so if the connection breaked, i want to handle this situation in my programm - how to do it?
|
|
|
|
|
|
Hello everyone,
I am working on a network program and
I want to lock the desktop and then put
something like a edit box on it.
How can I do that?
Best Wishes.
Thank.
|
|
|
|
|
Hello maybe one of you guys can help me out. im trying to write a program where it will execute another program with command line parameters.
Like in a bat file i would use
program.exe %param
just put it in a bat file and be on my way.
I would like to do this in C++. I need to make a exe that will execute a file.exe with %param aka %1.
plz lemme know. thanks.
|
|
|
|
|
Maybe you can use the "system()" function...
#include <process.h>
void main(char args[])
{
system(args);
}
so it can be for example as MSDN shows:
system( "type readme.txt" );
|
|
|
|
|
If you're under Windows, try using ShellExecute.
|
|
|
|
|
|
Hi!
I'll preface this by saying I'm a novice with C++ and the majority of my work is VB .Net, although in the past month I've had to take a self-crash-course in C++ for a project with some severely short deadlines, so I'm able to grasp basic C++ concepts. My C++ work at the moment involves writing my own C++ DLL to act as a join between a VB .Net application I am writing and an SDK that is designed for and writen in, C++ (I unfortunately lack the time to a solid course in C# and work with a more compatible pair of languages). The reason I'm writing this DLL is because certain uses of data types (unions being my biggest problem) used by the SDK aren't replicable in VB .Net (at least not to the best of my ability), and it's been easier to reproduce the functionality I need in C++ and send the data my VB .Net app needs back up the line.
Coming to my problem, the SDK is for a Canon line of digital cameras, and is used for manipulating the camera from a PC (taking pictures and getting live video, with a whole bunch of additional features on the camera you can access). My goal is to be able to take pictures (which I've fully accomplished), and get live video so that the user of my application can see what they're going to take a picture of before they do so. To put this in context, the app is for taking security badge photos.
The SDK handles video capture as sending to the PC what the digital view-finder on the camera can 'see', and it does this at a frame rate I think to be on the order of 25-29 fps, via an event call procedure I vaguely understand. Basically I create a pointer for the event that the initial function recognizes and then runs every time a frame of data is sent in from the camera, and then I write what code I want to in that event to display images. The event's parameters are a void field that is a buffer holding the data of the image, an unsigned long field holding the size of the buffer, another unsigned long field for the format (a 0 or 1 that I set as a seperate parameter of the initial function call to set the images coming back as bitmap or jpeg format, I'm using bitmap), and one more unsigned long field that I can use at my hearts content, but doesn't play any role in my needs.
Basically, I want to take what's in that buffer, and get it to my VB .Net application as a Byte array (in the .Net sense of the type) that I can then turn via a .Net memory-stream that data into a bitmap image (that final step being something I've done countless times before). My attempts at the moment have been to use a 'global' variable within my C++ DLL that I try to fill with the data from the buffer, and then I have a function of my own that returns the data from that global variable, and from my VB .Net app I just call that custom function however many times a second I want to.
The problem is I'm not getting any usable data, and my Byte array is showing up as having been accessed, but it has a length of 1. I presume this is because the data is being copied to it, but because I'm not so crash hot with C++ data formats, only the first byte of data is going into my array and nothing else (thus a length of 1, which obviously doesn't get me much).
I can provide sample code if it will help, but I wasn't sure it's necessary because I think my problem is not something particularly specific. Using a global unsigned long field I returned using my custom function, the Size field I mentioned earlier and it shows up as a little over 23,000, which would make sense for a 320x240 bitmap from the viewfinder (default size). I don't really know how to measure the buffer; I know of the sizeof() method but that for some reason was returning 4 to me when I used it on the buffer variable.
So my basic question follows my subject line (I hope so anyway!): How do I take the data out of a buffer that is of the Void data type, and copy it into a type that I can grasp from VB .Net as a Byte array?
Again, for reference. I have the buffer as a Void datatype, and the Size of the buffer, and I have the code in place to draw from a global variable that would be filled every time the viewfinder event is run by the SDK. My problem is I have had zero luck turning the buffer into a VB .Net Byte array.
Thanks so much in advance for any help or suggestions anyone can offer!
|
|
|
|
|
Could anybody please explain to me how to compile a source code split across 3 files, namely header file, implementation file and the driver file where the main resides. I tried every trick to no avail. I've tried the unix make utility but it was of no help. For some reason the linker may not be linking the header file because all the objects I created in the main are declared as undefined by the compiler.
|
|
|
|
|
Hello,
How to make IE Add-on for translating text?
During opening page I need to convert text to another language and show it in IE instead of original text.
Any idea, some example?
|
|
|
|
|
I'm just goofing off and I'm having an issue with my ifstream variable ifile when I attempt to close it. I sorta understand why it's not working but I don't know how to maintain my elegance and still accomplish my purpose. Here is a simplified portion of the code I have now:
<br />
<br />
string GetFilename(char []);<br />
ifstream& OpenFile(string);<br />
<br />
<br />
void main()<br />
{<br />
string input;<br />
ifstream ifile;<br />
<br />
input=GetFilename("manipulate:");<br />
ifile=OpenFile(input);<br />
if (ifile.fail()){<br />
cout<<"File does not exist!";}<br />
else{<br />
ifile.close();}<br />
}<br />
<br />
<br />
string GetFilename(char special[12])<br />
{<br />
static string input;<br />
<br />
cout<<"Please enter the name of the file you wish to "<<special<<endl;<br />
cin>>input;<br />
return input;<br />
}<br />
<br />
<br />
ifstream& OpenFile(string input)<br />
{<br />
static char filename[80];<br />
strcpy(filename, input.c_str());<br />
<br />
static ifstream ifile;<br />
ifile.open(filename);<br />
return ifile;<br />
}<br />
<br />
This program crashes when I try to close a file I opened that actually exists. I figure it has something to do with, am I closing the ifile is OpenFile or the one in main? A quick solution would be to create a global ifstream variable but how exactly does one effectively return an ifstream variable? The static declaration in OpenFile probably is causing havok too. Any help would be greatly appreciated.
P.S. I'll still be thinking on this for a while...
|
|
|
|
|
Give this a try:
string GetFilename( const char* );
ifstream OpenFile( const string& );
void main()
{
string input;
ifstream ifile;
input=GetFilename("manipulate:");
ifile=OpenFile(input);
if (ifile.fail()){
cout<<"File does not exist!";}
else{
ifile.close();}
}
string GetFilename( const char* special )
{
string input;
cout<<"Please enter the name of the file you wish to "<<special<<endl;
cin>>input;
return input;
}
ifstream OpenFile( const string& input )
{
ifstream ifile;
ifile.open( input.c_str() );
return ifile;
}
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
Well you helped make the code become simpler by this code I overlooked:
<br />
ifile.open(input.c_str());<br />
Thank you. Also I didn't know const was used in parameter passing to notify the compiler that the value would be left unchanged. Thank you #2. I can see I still have much to learn.
However closing the file still fails. I shall continue to work on this conundrum. If anyone would like to see the revised version, do say so.
|
|
|
|
|
Well... I tried making ifile a global variable. Doesn't work. In fact it only works if the ifile.open is inside the same function that closes it (main). Strange. I probably learned why a few years ago when I was taking intermediate c++, but now I've no clue. Oh well. I'll just leave it in main, no harm done ^_^. Thanks again for your help.
|
|
|
|
|
My mistake and yours.
The destructor will close the file. Change the code to:
bool OpenFile( ifstream& ifile, const string& );
...
ifstream ifile;
if ( OpenFile( ifile, input) )
...
bool OpenFile( ifstream& ifile, const string& input )
{
ifile.open( input.c_str() );
return !ifile.fail();
}
Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"
|
|
|
|
|
My project uses a resource that includes an Active X object, as well as buttons, edit boxes, etc. At run time there are many Modeless Dialogs that a user can start up using this resource. Each modeless Window opens and all are the same size. How can I make each modeless Window resizeable? I am not sure how resizing takes place in a project. Can someone help me out?
Thanks.
Jerry
|
|
|
|