|
Hi,
I'm using C++ in VS.NET. I've created an dialogbased MFC application.
How can I display a jpeg-picture in a dialog (MFC)? I wan't to load the picture from a file stored on my HD or/and from a char* pointing at the picture data.
Can I use the Picture Control or something easy like that?
|
|
|
|
|
Good news and bad news:
the picture control is for bitmaps only. Sorry. However, you could find a custom control that displays JPEGS and attach it to a CStatic object in your dialog. I couldn't tell you where this control could be found, but i'm sure it's out there somewhere.
-- Steve
|
|
|
|
|
You would have to use someone else's control to do that, cximage (an article on code project) seems like the most popular way to do this.
|
|
|
|
|
Here's my problem.
I've got an array of integers that are sorted. I want to find the number of elements between a range defined by a pair of values - lower and higher.
Okay so they are sorted, so I can just use a binary search on each value of a range, to find the element - but I'm not expecting exact matches so the nearest will do.
Also where there are duplicates, I want to find the lowest, and highest in respect to which value of the range I'm looking for. I don't want when searching for the low end to land first time on the right value, and find that its 1 of 3 duplicates and I may not have included it.
I cannot see anything in STL (I'm using a vector for now - though of using a multiset but not really great difference).
I could write my own with 2 binary searches leaning to finding the lowest, and the highest, but these things are frought with nast bugs, and I was hoping that someone else has done it - well they have - you need it for a database by using the BETWEEN statement in SQL!!!
Thing is I cannot find an implementation on google.
Any ideas?
"Je pense, donc je mange." - Rene Descartes 1689 - Just before his mother put his tea on the table.
Shameless Plug - Distributed Database Transactions in .NET using COM+
|
|
|
|
|
Giles wrote:
Okay so they are sorted, so I can just use a binary search on each value of a range, to find the element - but I'm not expecting exact matches so the nearest will do.
Well, binary search has pretty good time complexity - O(log2 n).
Is your array so large you want one better than that?
As for the duplicates, I'm stumped.
Vikram.
-----------------------------
My site due for a massive update.
"Good lord you yanks are getting worse than a defensive VB developer at a C++ conference." - Paul Watson in the Lounge, 31 May 2003.
"Do not give redundant error messages again and again." - A classmate of mine, while giving a class talk on error detection in compiler design.
|
|
|
|
|
No its not a large array, its just that I need to extend the binary searches so that rather than returning yes - a value exists and this is one of them, I need here are all the values between this range.
e.g.
Position/Value
0 2
1 7
2 7
3 14
4 15
5 16
6 20
7 21
8 21
9 22
I want the positions between and including 7 and 20
Poitions 1-6
Notice that I must not accidently think position 2 is the first - is the same value and must be included.
"Je pense, donc je mange." - Rene Descartes 1689 - Just before his mother put his tea on the table.
Shameless Plug - Distributed Database Transactions in .NET using COM+
|
|
|
|
|
You can use either a linear or binary search, however and inject a count and then just return the count. If you are familiar with the STL, you can implement a map and then use the equal_range member function.
-Nick Parker
|
|
|
|
|
Yep, I'm familiar with STL. Thing is, with equal_range on a map or set, it returns the iterators representing the start and end positions in the binary tree for which a number would not break the sorting. Its similar but no quite the same I think.
"Je pense, donc je mange." - Rene Descartes 1689 - Just before his mother put his tea on the table.
Shameless Plug - Distributed Database Transactions in .NET using COM+
|
|
|
|
|
There's a global version of binary_search in <algorithm> that you can use with your vector.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
you can use lower_bound and upper_bound to find the range.
there's a global version which can even be used on TYPE *'s
"Der Geist des Kriegers ist erwacht / Ich hab die Macht" StS
sighist | Agile Programming | doxygen
|
|
|
|
|
Is there a way to play a *.wav file wihtout having to link libraries to the project? Thanks
-KMaz
|
|
|
|
|
as far as i know only with linking a dll etc...
IceMatrix
|
|
|
|
|
I am using vc++ connect mysql server. How i going to add,delete and modify the data. I only know how to retrieve data.
siong
|
|
|
|
|
How are you connecting to the database (ADO, ODBC)? We need more information. To delete you can use an SQL query.
John
|
|
|
|
|
I am using mysql++ api to connect to mysql server.It is different from ado or odbc. Please help me!!! THanks....
|
|
|
|
|
Hi,
hope i've understood you right.
char sql[4000];
connection=mysql_real_connect(connection, host, user, passwd, db, 0, NULL, 0)
//add ist with insert into table values
sprintf(sql,"INSERT INTO %s VALUES (23 37 'test')",table); //e.g. i don't know your database
//modify ist with UPDATE and delete ist with DELETE FROM look api
mysql_query(connection, sql)
mysql_close(connection);
hope this helps
|
|
|
|
|
how to declare for the connection?
connection = mysql_real_connect();
siong
|
|
|
|
|
Oh sorry,
connection is a mysql-pointer;
MYSQL *connection;
|
|
|
|
|
Help me ,There still got big assertion error. What wrong with my code???
#define table "paises"
#define host "localhost"
#define user "admin"
#define passwd "123"
#define db "test"
char sql[4000];
CString d;
m_cboPais.GetLBText(m_cboPais.GetCurSel(),d);
//GetDlgItem(IDC_COMBO1)->GetWindowText(d);
// MYSQL mysql;
MYSQL *connection;
mysql_init(connection);
//mysql_options(connection,MYSQL_READ_DEFAULT_GROUP,"your_prog_name");
connection=mysql_real_connect(connection, host, user, passwd, db, 0, NULL, 0);
//add ist with insert into table values
sprintf(sql,"INSERT INTO %s VALUES (74 'dfdf' 0 'ey')",table); //e.g. i don't know your database
//modify ist with UPDATE and delete ist with DELETE FROM look api
mysql_query(connection, sql);
mysql_close(connection);
|
|
|
|
|
my fault,
your entries must be seperated be komma
sprintf(sql,"INSERT INTO %s VALUES (74, 'dfdf', 0 , 'ey')",table);
hope now ist works.
Heiko
|
|
|
|
|
Thank you very much!! U help me a lot!;P
I want to ask if u want to get the text u key in on combo box and then insert it into mysql database. How to get the text and then convert to vachar so that can insert into database?????
|
|
|
|
|
I don't know if i've understood you
get the text from combobox is:
CString str;
GetDlgItem(IDC_COMBO...)->GetWindowText(str);
convert str to char is with:
char test[100];
test=str.GetBuffer(str.GetLength());
|
|
|
|
|
That what i mean. But got error when i try to run it.
The error is below:
error C2440: '=' : cannot convert from 'char *' to 'char [100]'
There are no conversions to array types, although there are conversions to references or pointers to arrays
Thanks!
|
|
|
|
|
then use only the pointer
char *temp = str.GetBuffer.....
|
|
|
|
|
I change to pointer oledi but still cannot insert to database.
The 'test' is not recognize by the database and declase as char test to insert into database and not the text you key in. Help me please
MYSQL mysql;
//MYSQL *connection;
CString str;
GetDlgItem(IDC_COMBO1)->GetWindowText(str);
char * test;
test=str.GetBuffer(str.GetLength());
mysql_init(&mysql);
mysql_options(&mysql,MYSQL_READ_DEFAULT_GROUP,"your_prog_name");
mysql_real_connect(&mysql,"localhost", "admin", "123", "test", 0, NULL, 0);
sprintf(sql,"INSERT INTO %s (CodPais,Nombre,Prefijo,Code) VALUES ('auto','test','','te')",table); //e.g. i don't know your database
//modify ist with UPDATE and delete ist with DELETE FROM look api
mysql_query(&mysql, sql);
//add ist with insert into table values
mysql_close(&mysql);
MessageBox("Data telah ditambah");
|
|
|
|