|
I want to popup a message, while closing (x) the dialog box.. how to do that.. I am using modeless dialog..can anyone help..
chitra
|
|
|
|
|
overwrite the onsyscomman() in your dialog box.
Greetings from Germany
|
|
|
|
|
I'm having a windows forms application project. On the form there's a datagridview with data of a table out of the datasources. The connectionstring in the datasource is made by the add new datasource wizard and is : Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\test\Tabel-XML.mdb
Changing it in the _Tabel_XMLDataset.h file doesn't do anything and changes after a new build.
Now I'd like to know if it's possible to change my data source, so make it variable. I saw something about the use of app.config but how do i have to do this then so that the data source of my datagridview is changed without rebuilding my project it each time after creating a new databaseconnection. I'd like to define the databaseconnection in an external file (like app.config) and then use this databaseconnection for my project. How is this done?
Thanks for helping me out
|
|
|
|
|
hi
I need to call the following function somewhere in a program:
void __fastcall TFormMain::btnUpdateClick(TObject *Sender)
{.....}
This is the event of mouse-click on a button.
How can i call this function in the program itself (which otherwise gets called on 'mouse-click'??
|
|
|
|
|
Does Builder support Microsoft .NET, or are you in the wrong forum ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
No, BUilder doesnt support Microsoft.NET...it apparently is not a Microsoft product
|
|
|
|
|
Borland do do products that support .NET, I thought. But, if that's not one, try the visual c++ forum.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I want to create some data classes for my Form but the designer requires the first class be for the form. Is there a cleanest way to add this class to the same document as the form’s design?
Thanks
Programmer
Glenn Earl Graham
Austin, TX
|
|
|
|
|
Put your data classes in a header file and include it before your Form class. Also, you may need to add some namespace references for it to compile properly.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
I have implementation problems with consumer and procedur. How I can improve this code for good at synchronous communicating?
#include fcntl.h
#include semaphore.h
#include pthread.h
#include stdlib.h
#include stdio.h
#include sys/types.h
#include unistd.h
sem_t *mySemaphore ;
#define BUFFERSIZE 1000000
char boundedBuffer[BUFFERSIZE] ;
int filled = -1 , empty = -1 ;
void Produce(void *data) {
int i = 0 ;
while ( i < BUFFERSIZE ) {
boundedBuffer[++filled] = 'A' ;
i++ ;
}
}
void Consume(void *data) {
int i ;
while ( i < BUFFERSIZE) {
if ( boundedBuffer[++empty] != 'A' )
printf("Error consume != A\n"); ;
i++ ;
}
}
int main(int argc, char * argv[]) {
pthread_t p1, p2 ;
int l = 0 ;
mySemaphore = sem_open("MySemaphore",O_CREAT) ;
for ( l = 0 ; l < BUFFERSIZE; l++) boundedBuffer[l] = '.' ;
/* Create our threads */
pthread_create(&p1, NULL,(void *(*)(void *)) Produce, boundedBuffer);
pthread_create(&p2, NULL,(void *(*)(void *)) Consume, boundedBuffer);
/* Wait for our threads */
pthread_join(p1, NULL);
pthread_join(p2, NULL);
return 0 ;
}
|
|
|
|
|
There is no .NET code in your post, you are therefore in the wrong forum. Try the Visual C++ forum.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi everybody
I am new member and have recently started developing my site. PLease don't have a go atme if this hte wrong programming language as i have a very limited knowledge of programming, but anyway. Please could someone give me the code or tell me how to write a forum for my website. I need to be able to put it in visual web developer 2005
thanks
smartiejoe
making firends
wherever you go
just making friends
|
|
|
|
|
This is my son!! Go easy on him. I have already given him the necessary abuse for posting in the wrong forum.
And he will be changing his sig!
<mod> I've just read his post - "please give me the code" - unbelievable!!! You all have full permission to go for him!
I'll go and have a word....with a sharp stick
</mod>
"More functions should disregard input values and just return 12. It would make life easier." - comment posted on WTF
"This time yesterday, I still had 24 hours to meet the deadline I've just missed today."
|
|
|
|
|
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
|
Hi
I've got a jpg file which I'd like to read.
When using od in UNIX, I can get a hex version of its contents:
$ od -x file.jpg | head<br />
0000000 d8ff e1ff 8711 7845 6669 0000 4949 002a<br />
0000020 0008 0000 000b 010e 0002 0015 0000 0092<br />
0000040 0000 010f 0002 0018 0000 00b2 0000 0110<br />
0000060 0002 0005 0000 00d2 0000 0112 0003 0001<br />
0000100 0000 0001 0000 011a 0005 0001 0000 00e2<br />
0000120 0000 011b 0005 0001 0000 00ea 0000 0128<br />
When using this simple program, most of the values I read have a strange value:
#include "stdafx.h"<br />
#include <iostream><br />
#include <fstream><br />
<br />
using namespace std;<br />
ifstream::pos_type size;<br />
char * memblock;<br />
<br />
<br />
int main () <br />
{<br />
ifstream file ("y:\\EXIF\\sanyo-vpcg250.jpg", ios::in|ios::binary);<br />
if (file.is_open())<br />
{<br />
size = file.tellg();<br />
memblock = new char [size];<br />
file.seekg (0, ios::beg);<br />
file.read (memblock, size);<br />
file.close();<br />
<br />
cout << "the complete file content is in memory";<br />
<br />
char x=memblock[0];<br />
delete[] memblock;<br />
}<br />
else cout << "Unable to open file";<br />
return 0;<br />
}
The x value becomes 0xfd in the debugger (in vs.net using windows xp).
What's going wrong? And how can I get an output like the one using od?
-- modified at 19:58 Friday 28th September, 2007
Woops, should be moved to: http://www.codeproject.com/script/comments/forums.asp?forumid=1647
|
|
|
|
|
The first byte you should see is 0xFF.
Try changing the memblock type to BYTE (unsigned char) since you're
working in binary.
After the read() call, look at memblock in the debugger. Should be FF D8 FF E1...
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Also
tellg() is probably returning 0.
To get the file length, you need to seek to the end before calling tellg...
...<br />
file.seekg(0, ios_base::end);<br />
size = file.tellg();<br />
...<br />
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
That is indeed the solution.
thanks a lot
unsigned char's aren't to be used by read I guess (after having looked at the function's signature).
So that wasn't quite an option, I'm afraid.
|
|
|
|
|
GentooGuy wrote: unsigned char's aren't to be used by read I guess (after having looked at the function's signature)
Yes, but in binary mode, you really aren't dealing with char so a cast can be appropriate.
It depends on the data in the file....if it was really all char data then you probably wouldn't be
using binary mode.
Whatever works for you - in the end you're reading bytes and you'll need to cast them to
something else eventually
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Okay thanks for the advice.
Currently, I'm having another small (I hope) problem:
#include "stdafx.h"<br />
#include <iostream><br />
#include <fstream><br />
<br />
using namespace std;<br />
ifstream::pos_type size;<br />
char * memblock;<br />
<br />
void swapByteOrder();<br />
int readFile(char *filename);<br />
void printFile(int nr);
<br />
int main () <br />
{<br />
if(!readFile("y:\\EXIF\\sanyo-vpcg250.jpg"))<br />
{<br />
cout <<"Some error occurred while opening the file"<< endl;<br />
return 1;<br />
}<br />
printFile(10);<br />
cout << endl;<br />
swapByteOrder();<br />
printFile(10);<br />
return 0;<br />
}<br />
<br />
<br />
<br />
int readFile(char *filename)<br />
{<br />
ifstream file (filename, ios::in|ios::binary);<br />
if (file.is_open())<br />
{<br />
file.seekg(0, ios_base::end);<br />
size = file.tellg();<br />
memblock = new char [size];<br />
file.seekg (0, ios::beg);<br />
file.read (memblock, size);<br />
file.close();<br />
<br />
cout << "the complete file content is in memory\n";<br />
<br />
cout << "Size : "<< size << endl;<br />
for(int i=0;i<100;i++)<br />
{ <br />
char x = memblock[i];<br />
cout << hex << (int)memblock[i]<<endl;<br />
} <br />
<br />
delete[] memblock;<br />
}<br />
else cout << "Unable to open file";<br />
return -1;<br />
}<br />
<br />
<br />
void swapByteOrder()<br />
{<br />
long max = size;<br />
char temp;<br />
for(int i=0 ;i<max-2; i+=2)<br />
{<br />
temp=memblock[i];<br />
memblock[i]=memblock[i+1];<br />
memblock[i+1]=temp;<br />
}<br />
}<br />
<br />
<br />
void printFile(int nr)<br />
{<br />
for(int i=0;i<nr ;i++)<br />
{<br />
cout << hex << memblock[i] << endl; <br />
}<br />
<br />
}
The SwapByte function gets a access violation, when reaching i==3992. This is strange because it should be able to run to 62096 (the lenght of the file , as indicated by size).
What's going wrong here?
|
|
|
|
|
I'm surprised it gets that far, since you delete memblock in readFile()
I'm curious....why are you reading bytes from a jpeg file as ints
cout << hex << (int)memblock[i]<<endl;
and why would you be swapping byte order? Are you trying to make the jpeg unreadable?
Actually, this whole loop doesn't make sense
for(int i=0;i<100;i++)<br />
{ <br />
char x = memblock[i];<br />
cout << hex << (int)memblock[i]<<endl;<br />
}
You're indexing the array by bytes but casting to int (4 bytes)???
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Well I got confused too. I'm java developer (bsc. in CS) but I'm getting quite stuck on this one.
Manual GC isn't exactly my cup of tea
Well, I want to retrieve some EXIF information from the file, and when not swapping the bytes (hey, I do NOT write the array to disk) I get the same ouput as when using od (UNIX tool for displaying files).
So I thought, I had a byte-order related problem.
od output:
0000000 d8ff e1ff 8711 7845 6669 0000 4949 002a<br />
When running my own app, I found a ff first, then the d8, an ff, the e1, the 11, the 87. etc...
That's my reason to swap these bytes.
|
|
|
|
|
Hi,
A typical JPEG hex dump starts like this:
000000 FF D8 FF E0 00 10 4A 46 49 46 00 01 02 01 00 87
000010 00 87 00 00 FF ED 08 9E 50 68 6F 74 6F 73 68 6F
i.e. the very first byte is FF.
If you interpret that as a number of 16-bit words (as your od command seems to do)
then you would get D8FF E0FF etc. but that does not mean this is how you should look at it.
In fact JPEG coding is byte oriented, each FF XX pair of bytes marks the start of something
and may be preceeded by an arbitrary number of FF bytes.
I suggest you:
- start by reading the JPEG standard, you can find it on the web;
- look at JPEG files with an unbiased tool, one that shows bytes, not larger integers.
BTW: if you read a JPEG file with Image.FromFile() the Image class will offer access
to a lot of metadata as well (e.g. GetPropertyItem() method)
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
thanks for the info.
nut the image class is .net based, and I don't want just plain C++ without ms specific stuff.
|
|
|
|