|
i am using vc++6 MFC and dialogs
i want to connect to my remote mysql database and put the results in a CListView, any example i find uses ODBC, where a window box is poped up and a you have to select a ODBC. can i not just connect directly to the mysql server?
Or if a OBDC has to be used can i hard code one in and how?
thanks
|
|
|
|
|
1. go to mysql.com to download c library, which contains c functions for accessing mysql database and is free.
2. go to your host to add your PC's IP address to mysql database, otherwise you can not access your mysql database.
A nice tool for optimizing your Microsoft html-help contents.
Includeh10
|
|
|
|
|
ah right, im am using a mysql wrapper already (MySQLWrapp), was just wondering how to get the data into a CListView. like all the columns and rows. all the examples show how with ODBC
|
|
|
|
|
if u can read records from mysql db, why can't u add them to CListView?
is ur question about mysql or CListView?
A nice tool for optimizing your Microsoft html-help contents.
Includeh10
|
|
|
|
|
i think his problem is MFC because he's been asking so manu times about data binding...
see by your eyes[^]...
|
|
|
|
|
I have a CDialog derived class, and want to programmatically close it. I tried:
cd->PostMessage(WM_CLOSE);
where cd is the pointer to the non-modal window. However it doesn'tclose. In the message map of cd's class I put ON_WM_CLOSE()
BEGIN_MESSAGE_MAP(CDlgTimeSeries, CDialog)
ON_WM_CLOSE()
END_MESSAGE_MAP()
What do I need to do to close this cdialog?
thanks,
sb
|
|
|
|
|
call function OnOK() or OnClose().
OnOK() returns IDOK.
OnCancel() returns IDCANCEL.
A nice tool for optimizing your Microsoft html-help contents.
Includeh10
|
|
|
|
|
Use DestroyWindow() to close a modeless dialog
cd->DestroyWindow(); Your dialog will then recieve a WM_DESTROY and a WM_NCDESTROY message.
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
Thanks! That worked great!
|
|
|
|
|
WM_CLOSE is sent to windows (generally top level windows, or child MDI windows) by the system, asking them to close. The default handler (DefWindowProc()) for WM_CLOSE calls DestroyWindow(). It would seem that DefDlgProc() doesn't call DestroyWindow() (which makes sense, since a dialog may be modal, and is handled a bit differently).
--
Pictures[^] from my Japan trip.
|
|
|
|
|
I have a series of 32 frames of data (all the same size in RGB format) which I would like to show in an AVI format. I don't need any audio, just video. I tried my luck at AVIFileInit() followed by AVIFileOpen(&pfile, name, OF_WRITE | OF_CREATE, NULL);
These worked (no error code) and AVIFileCreateStream(pfile, &ps, &strhdr); even worked.
When I made my data into a bitmap and tried to insert it with
hr = AVIStreamWrite(ps, i, 1, buff, bi.biSizeImage, AVIIF_KEYFRAME, NULL, NULL);
my luck ran out.
Presumably my strhdr isn't properly defined
memset( &strhdr, 0, sizeof(strhdr));
SetRect(&strhdr.rcFrame, 0, 0, (int) bi.biWidth, (int) bi.biHeight);
strhdr.fccType = streamtypeVIDEO;
strhdr.fccHandler = mmioFOURCC('M','S','V','C');
strhdr.dwScale = 1;
strhdr.dwRate = 1;
strhdr.dwQuality = -1; // default quality
I have no idea what MSVC in fccHandler means, for example.
I would like it to work like clock.avi in c:\windows which clicks away at 1 second clicks and it cycles back on itself. Does anyone have any suggestions on a tutorial?
Thanks,
Ilan
|
|
|
|
|
As usual, searching CodeProject articles is a good place to start - there is an article called "A simple interface to the Video for Windows API for creating AVI movies from individual images" (and here's the link: http://www.codeproject.com/audio/aviutil_.asp[^])
I have no idea how well this article works - it didn't get a great score, but it may give you some tips.
|
|
|
|
|
There is a way to associate a process to their sockets/connection without IP Helper?
[.KuRLiC.]
|
|
|
|
|
I have a somewhat obscure question about constructors, which I have not been able to find an appropriate answer for. I will preface my question by describing the situation:
I have a class representing a board that requires initialization. I know that the constructor should deal with storing addresses and other information about the board. However, should it also perform the initialization? In other words, can the constructor do more than just initialize member variables and perform an action, or is this considered bad programming practice?
If you can do initializations in the constructor, how do you return the result of that initialization? I need to know whether the physical board was actually located and configured. Can I pass a pointer (for example, initResultPtr) to the constructor such that it can update a variable that can be used to verify the result of the initialization?
Or should my class have a constructor that initializes all the member variables and an init() function that performs the physical board initialization and returns the result of that operation?
What it is the standard practice for this problem? If you have an opinion or can refer me to an accepted answer to this problem, I would be very grateful.
Kiernan
|
|
|
|
|
the constructor can perform whatever actions, but if it becomes very far from the purpose of initializating its instance, you can consider it is a bad pratice to do so. however, if you really need to do so, then write this code in another function, and call this function inside the constructor. of course, be careful that, if the function handles some uninitialized data members, you could go into trouble !
|
|
|
|
|
Generally speaking, I think constructors should be rather lightweight and only initialize variables. This is mostly because constructors can not return a status. Customary practice dictates that an exception is thrown on failure and that may not always be the prefered option. I prefer that any 'heavy lifting' be done in specific methods.
Regarding constructors failing : http://www.parashift.com/c++-faq-lite/exceptions.html#faq-17.2[^]
BTW - not that they're the final authority or anything, I just found them first in my search.
|
|
|
|
|
Hello comunity,
i look for a funktion for CString's, funktion who is not casesensitive!
My problem is that i do mutch with Files, and a search in them, but when i use
the funktion from CString::Find(); , i have an problem that they 'r casesensitive,
for example, when i look for string like "code", is not the same like "CODE"!
Is here any god function for search in strings
example:
<br />
CString csString = L"THE CODE PROJECT";<br />
int iPos;<br />
<br />
iPos = csString.Find(L"code");
iPos = csString.Find(L"CODE");
<br />
"code" is in string, but i recive -1 as return value!!!
thax for any help
break;
|
|
|
|
|
And what about converting the CString to upper or lower case first (with CString::MakeUpper and CString::MakeLower). If you don't want to modify the case of your string, you can first store it in a temporary string that you modify and work with it.
|
|
|
|
|
Hello Moonen,
in some case is this a good idea, but i can't change all file content, because this change the file, and i want to extract some parts of this file and store it
in a new varable for later to compare and some other functions!
but tanx for reply
break;
|
|
|
|
|
break; wrote: Hello Moonen
It is Cedric or Mr.Moonen.
break; wrote: but i can't change all file content, because this change the file
What Cedric meant is that you can use a temporary string which you can manipulate as you wish to get the index returned by the Find function, and then use this index on the real variable, namely this one:
break; wrote: store it
in a new varable for later to compare
~RaGE();
|
|
|
|
|
uups, sorry
thanx
break;
|
|
|
|
|
You could derive a custom string class from CString and overload the Find function:
class CMyCString : public CString
{
int Find(LPSTR lpszSub, int startAt=0);
}
int CMyCString::Find LPSTR lpszSub, int startAt)
{
CString s1 = *this; //make a copy of the current string
CString s2 = lpszSub;
//Make both strings uppercase
s1.MakeUpper();
s2.MakeUpper();
return s1.Find(s2,startAt);
}
You would then be able to use your custom class in place of CString.
|
|
|
|
|
hello,
thanx for reply, i try your sample!
regards
break;
|
|
|
|
|
Heya everybody. I got a question about WM_NCHITTEST...
I got a window with thick border and to prevent the user to resize it, I have to interpret WM_NCHITTEST and return HTBORDER when the mouse is over the border. However... the question is... is there an easy way to know when the mouse is over the border??? Or do I have to make some arithmetical checks for this? As far as I see the problem right now, the only way to determine when the mouse is over a border is to calculate by using the lParam of WM_NCHITTEST which tells me screen-relative X/Y position.
-= E C H Y S T T A S =-
The Greater Mind Balance
|
|
|
|
|
I did a test for you, add the 3 lines:
//===============================
CMenu*pMu=GetSystemMenu(0);
pMu->RemoveMenu(SC_SIZE,MF_BYCOMMAND);
ModifyStyle(WS_MAXIMIZEBOX,0);
//===============================
the window will not be sized.
A nice tool for optimizing your Microsoft html-help contents.
Includeh10
|
|
|
|