|
Hi, I want to know is it possible to make multiple CRecordset derived class in 1 project?? Because I tried to add another CRecordset derived class to my Single Document Project, It couldn't run... Please help.... I need to connect to different Tables seprately not all in one...
Thank YOu
|
|
|
|
|
Why not something like:
CDatabase database;<br />
CString sSql;<br />
<br />
sDriver = GetExcelDriver();<br />
if (sDriver.IsEmpty())<br />
{<br />
AfxMessageBox("No Excel ODBC driver found");<br />
return;<br />
}<br />
<br />
sDsn.Format("ODBC;DRIVER={%s};DSN='';DBQ=%s", sDriver, m_sFileName);TRY<br />
{<br />
database.Open(NULL, false, false, sDsn);<br />
<br />
CRecordset recset(&database);<br />
<br />
sSql = "SELECT Date, Heure, " + m_sColumn + " FROM [Feuil1$A1:IV65536] WHERE Operateur='SFR'";<br />
<br />
recset.Open(CRecordset::forwardOnly, sSql, CRecordset::readOnly);
while (!recset.IsEOF())<br />
{<br />
recset.GetFieldValue(m_sColumn, sValue);<br />
recset.GetFieldValue("Date", sDate);<br />
recset.GetFieldValue("Heure", sHeure);<br />
<br />
if(-1 != sDate.Find(strDate))<br />
{<br />
int iSpacePos = sHeure.Find(" ");<br />
if(-1 != iSpacePos)<br />
{<br />
sTime = sHeure.Right(sHeure.GetLength() - iSpacePos);<br />
sTime.TrimLeft();<br />
sTime.TrimRight();<br />
<br />
sHour = sTime.Mid(0, 2);<br />
sMinutes = sTime.Mid(3, 2);<br />
sSeconds = sTime.Mid(6, 2);<br />
<br />
CTime tTime(2000, 1, 1, atoi(sHour), atoi(sMinutes), atoi(sSeconds));<br />
m_aTimes.Add(tTime);<br />
}<br />
<br />
m_doubleArray.Add(atof((LPCTSTR)sValue));<br />
}<br />
<br />
recset.MoveNext();<br />
}<br />
database.Close();<br />
<br />
}<br />
CATCH(CDBException, e)<br />
{<br />
AfxMessageBox("Database error: " + e->m_strError);<br />
}<br />
END_CATCH;
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
fba218 wrote:
...is it possible to make multiple CRecordset derived class in 1 project??
Sure it is.
fba218 wrote:
It couldn't run
Meaning what? Did you get a runtime error, assertion, exception?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
This is the code I used to create my own message box in win32.
char *tstr;
BOOL CALLBACK DProc (HWND hDlog, UINT message, WPARAM wParam,
LPARAM lParam)
{
switch (message)
{
case WM_INITDIALOG:
{
SetDlgItemText(hDlog,IDC_TEXTMSG,tstr);
SetWindowPos(hDlog,HWND_BOTTOM,600,500,NULL,NULL,SWP_NOSIZE);
return TRUE;
}
case WM_COMMAND:
switch(LOWORD(wParam))
{
case IDOK:
DestroyWindow (hDlog);
return TRUE;
}
case WM_DESTROY:
DestroyWindow (hDlog);
return TRUE;
case WM_CLOSE:
DestroyWindow (hDlog);
return TRUE;
default:
return DefWindowProc(hDlog, message, wParam, lParam);
}
return FALSE;
}
int MsgBox(char *textstr, HWND hParDlg)
{
tstr = textstr;
HWND hDg = 0;
HINSTANCE hIn = NULL;
hDg = CreateDialog (hIn,
MAKEINTRESOURCE (IDD_MSGDLG),
hParDlg,
DProc);
if (!hDg)
{
MessageBox (0, "CreateDialog returned NULL", "Warning", MB_ICONEXCLAMATION | MB_OK);
return 1;
}
else
{
ShowWindow(hDg, SW_SHOW);
UpdateWindow(hDg);
}
MSG msg;
int status;
while ((status = GetMessage (& msg, 0, 0, 0)) > 0)
{
if (status == -1)
return -1;
if (!IsDialogMessage (hDg, & msg))
{
TranslateMessage ( & msg );
DispatchMessage ( & msg );
}
}
return 0;
}
I call this function in various places to dispaly my message box. eg. MsgBox("Cannot open the file",hDialog);
It's creating the displaying the message box but after closing the message box the control is not returned to my parent Dlg (hDilaog). What did I missed here?
Plz someone help.
Thanks in advance.
|
|
|
|
|
magee81 wrote:
while ((status = GetMessage (& msg, 0, 0, 0)) > 0)
Try this:
while ((status = GetMessage (& msg, 0, 0, 0)) > 0 && IsWindow(hDg)) Basically, your message loop would only terminate when it received a WM_QUIT, which would terminate your application.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
I've created 2 classes with baseclass CDialog. The first class should show the other dialog while working.
I've done it that way:
void CTestDlg::OnTest() <br />
{<br />
UpdateData(TRUE);<br />
CWaitDialog *wd=new CWaitDialog;<br />
<br />
if (!::IsWindow(wd->GetSafeHwnd()))<br />
wd->Create(IDD_DIALOG2, this);<br />
<br />
wd->ShowWindow(SW_SHOW); <br />
<br />
<br />
wd->EndDialog(0);<br />
wd=NULL;<br />
<br />
<br />
UpdateData(FALSE);<br />
delete wd;<br />
}
The second dialog shows up, but I can not move it or it doesn't react on
input. When I show the dialog only without letting the first dialog do his work the second reacts as expected. So my question is how to create modeless windows like the one when copying or saving files? I think of the typical "work in progess" dialogs, showing the effort and let you quit the action.
|
|
|
|
|
you could try doing some message pumping in the "word to do" section. it could be that the modeless dialog is never given a chance to process any windows messages.
Software | Cleek
|
|
|
|
|
It might be the reason. Since I'm not very familiar with that topic, any recommends?
|
|
|
|
|
here's a basic MsgPump function:
<br />
void MsgPump(DWORD dwLen )<br />
{<br />
MSG m_msgCur;
<br />
CWinApp *pWinApp = AfxGetApp(); <br />
<br />
DWORD dInitTime = GetTickCount();<br />
<br />
while (::PeekMessage(&m_msgCur, NULL, NULL, NULL, PM_NOREMOVE) &&<br />
(GetTickCount() - dInitTime < dwLen) )<br />
{<br />
pWinApp->PumpMessage();<br />
}<br />
<br />
}<br />
Call this periodically in the code where you do your work. You don't have to call it all the time, just once in a while. The dwLen is the number of ticks to wait. 200 is a good default.
-c
Software | Cleek
|
|
|
|
|
Thank you! It worked perfect. Even when dwLen=1 it is enough to make the second dialog accessable.
|
|
|
|
|
ryuki wrote:
wd->EndDialog(0);
EndDialog() is specific to modal dialog boxes.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Alternatively to the message pump, you can create a worker thread to do your job. There are some excellent articles in CodeProject about it (here for instance)
|
|
|
|
|
Hello, all. I'm trying to have the program I'm writing raise its class and thread priorities on a button click. I can change the thread priorities just fine, but I'm having trouble with the priority class. Here's the code from the function that I'm using to change the priorities:
HANDLE Hand;
BOOL Check;
DWORD Error;
Hand = GetCurrentThread();
Check = SetPriorityClass(Hand, HIGH_PRIORITY_CLASS);
Error = GetLastError();
Check = SetThreadPriority(Hand, THREAD_PRIORITY_HIGHEST);
Error = GetLastError();
Does anybody have any idea why I can change the thread priority but not the priority class?
Thanks,
Phillip
|
|
|
|
|
BOOL SetPriorityClass(
HANDLE hProcess, // handle to the process
DWORD dwPriorityClass // priority class value
);
GetCurrentProcess will give u the handle of the current process
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Thanks for your help! Your solution works great!
Thanks,
Phillip
|
|
|
|
|
Hello,
I am using a CRichEditCtrl-derived class and I am setting it to use a bitmap .FON font. .FON fonts use 8-bit encoding and thus cannot support more than 255 characters. Everything works fine when I type in english, but when I switch to another language-keyboard, the font inside the CRichEditCtrl changes to some default (arial). I suppose this has something to do with using unicode (I work in WinXP) encoding, which is 16-bit and thus it does not correspond to any character in the bitmap font.
So, is there a way I can work around this to show my bitmap font?
Have no fear of perfection - You will never reach it
|
|
|
|
|
Just curious if there is an easy way to programatically retrieve the timestamp of a digital certificate?
Thanks in advance,
Colin Soule
|
|
|
|
|
Is it possible to add to #_DEBUG and #_RELEASE modes in order to accomplish compiling certain parts of a program vs leaving it out of the finished executable? That is _RELEASE mode leaves out all the _DEBUG pieces of code but is it possible to have another version of _RELEASE for example called _BASIC or _PROFESSIONAL whereas parts of the program would be a part of the completed .exe in _PROFESSIONAL and be excluded in _BASIC?
So far I have just placed the following in StdAfx.h
#define _BASICRELEASE
#define _PROFESSIONALRELEASE
whereas, leaving both uncommented gives the Professional release and commenting out PROFESSIONALRELEASE will give me a BASICRELASE.
However I would like to accomplish this like I would with Project Settings so that it gets augmented to all of my DLL's. Is this possible?
I hope I described that well.
Thanks!
|
|
|
|
|
Yes, it is possible.
First, you'll probably want to clone your current "Release" configuration, so you can have a "Baisc Release" and "Professional Release". (In VS.NET, there is a "Configuration Manager" button if you go to Project Settings, you can do it there. I forget where it is in VS 6.)
Once you've done that, you can go to your Project settings, C/C++, Preprocessor, and there is a line saying "Preprocessor definitions". Just add, say, _BASICRELEASE as a preprocessor definition for the "Basic Release", etc.
"Fish and guests stink in three days." - Benjamin Franlkin
|
|
|
|
|
Thanks! I understand and have implemented it! Cool!!
|
|
|
|
|
I have recently spent some time getting some of my apps looking right on XP styles, by adding a manifest resource, and also modifying some controls that are custom-drawn.
However, if I use my xp-style-enabled controls in apps which do not have a manifest, and therefore draw using the old style, I find that my controls still draw with the current XP style. I have used IsAppThemed() as a way of determining how to draw my controls, but I have found that this returns TRUE even though the app is not XP-style-enabled, making the control look odd! I have tried using IsThemeActive but this also always returns TRUE.
Does anyone know how I can find out if the app is XP-styled (ie the other controls are using the XP-styles)?
"The way of a fool seems right to him, but a wise man listens to advice" - Proverbs 12:15 (NIV)
|
|
|
|
|
Dear Friends,
I would like to develop an application, which can display a image to a Projector instead of a Dialog's Display.
Please help to solve this problem. Is it possible to display the Dialog's display on a Projector? Any kind of suggesion will be highly appriciable. Please help me soon.
Thanking you in advance.
Billar
|
|
|
|
|
Billar wrote:
...display a image to a Projector...
Do you mean something like this that connects to the video card's S-video port?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Yes,
But I would like to develop an application which captures an image from camera and display it to a Projector.
Waiting for your response.........
Billar
|
|
|
|
|
I don't see that anything extra is required. Just display the image as you normally would, and if a projector is connected to the video card's S-video port, it will show up there too.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|