|
try {
_CommandPtr cmd;
_ParameterPtr prmStudyNumber;
_ParameterPtr prmCadSysNumber;
_RecordsetPtr pRstCase = NULL;
TESTHR(cmd.CreateInstance(__uuidof(Command))); // Test a hresult
CString tempStr;
tempStr.Format("SELECT * FROM %s ;","CountPerCaseStatsCueType");
// CountPerCaseStatsCueType is a view "Query" in an access 2000 db that has 2 parameters
cmd->ActiveConnection = GetConnection(); // My function that returns a _ConnectionPtr that is open from a previous call
cmd->CommandText = _bstr_t(tempStr);
prmStudyNumber = cmd->CreateParameter(_bstr_t("StudyParam"),adInteger,adParamInput,-1,_variant_t((long)nStudy));
cmd->Parameters->Append(prmStudyNumber);
prmCadSysNumber = cmd->CreateParameter(_bstr_t("CadSysParam"),adInteger,adParamInput,-1,_variant_t((long)nCadSys));
cmd->Parameters->Append(prmCadSysNumber);
// NOTE: The Database will ignore the parameter names so you must place the parameters in the same order as you
// have defined in your view "query".
CStringEx str;
_variant_t var;
_variant_t v1(DISP_E_PARAMNOTFOUND,VT_ERROR);
_variant_t v2(DISP_E_PARAMNOTFOUND,VT_ERROR);
pRstCase = cmd->Execute(&v1,&v2,adCmdText);
while(!pRstCase->adoEOF) {
// Do something with the data
pRstCase->MoveNext();
}
}
catch (_com_error &e)
{
GenerateError(e.Error(), e.Description()); // My error message handler
}
catch( CException* e)
{
GenerateError(e);
}
catch (...)
{
m_pDoc->GetLog()->LogTime();
m_pDoc->GetLog()->Log("\nDATABASE ERROR: Unknown Exception in CCaseDataBase::GetCaseCoverageTypeStatisticsAll()");
}
I took this code out of one of my recent projects, I hope this helps.
John
|
|
|
|
|
CString strQuery = _T("");
strQry.Format(_T(sp_StoretClientFields_ps '%s', %d"), (LPCTSTR)strParam1, nParam2);
//strParam1 is String and nParam2 is numeric.
if you want see:
http://www.codeproject.com/useritems/caaadoclass1.asp
Here you can see a sample and a class, for use this.
If you want, please contact me at carlos.antollini@nixorcorp.com
Carlos Antollini.
|
|
|
|
|
Are there any reusable datetime classes that are freely distributed.
I'm currently using the tm struct & CTime in MFC to work with dates.
I'm looking for a good datetime class with validation on dates built-in.
Thanks,
Gerry.
|
|
|
|
|
My dialog agree to apear whole only in specified resulution.
How can I do that its size will be fit to every resulution.
URGENT !!!
|
|
|
|
|
The reason it is *urgent* is that you've failed to apply the good advice on this question given several times already.
The function you need to call is called MoveWindow, the function that tells you the size of the screen is GetSystemMetrics, and you can override your OnSize function if you want to move your controls relative to your new window size.
If you find yourself still unable to fix this simple problem with the oodles of help you have recieved, consider posting the code you have written, so we can offer suggestions based on where you are going wrong.
Christian
#include "std_disclaimer.h"
|
|
|
|
|
Please! who can show me what I need to change here for that problem
void CRegWinDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
//this->MoveWindow(cxIcon, cyIcon, m_hIcon, true);
CRect rect; //this->MapDialogRect(&rect);
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
|
|
|
|
|
The paint handler effects how the area is painted, not how big the dialog actually is. The handler under the check for IsIconic draws the icon.
You need to over ride OnInitDialog, where you can do what I suggested ( get the dimensions using GetSystemMetrics and call MoveWindow ), although MapDialogRect looks like a better idea, I have never used it before so I cannot comment. ( I intend to though, it looks useful ).
I'd suggest trying MapDialogRect first, and doing it in OnInitDialog.
Christian
#include "std_disclaimer.h"
|
|
|
|
|
I did so and this problem remain
BOOL CRegWinDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
MapDialogRect(&rect);
//GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
CPaintDC dc(this); // device context for painting
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
//this->MoveWindow(cxIcon, cyIcon, x, y);
}
|
|
|
|
|
I'm not sure why you expect this to work, but I'd suggest that when people give you advice you seek to learn *how* something works so that you don't have to ask again. You have copied a lot of code that came for free in your OnPaint, which, as I explained before, has nothing to do with what you want.
Here is the total solution. Please take the time to understand how it works, it is with the hope that people will *learn* that I spend time here answering questions.
MoveWindow(0, 0, GetSystemMetrics(SM_CXFULLSCREEN), GetSystemMetrics(SM_CYFULLSCREEN));
This moves the window to fit exactly onto the screen - you will probably have to subract from the last parameter in order to allow for the taskbar. I am not sure at this late hour how to go about figuring out the available screen area taking into account the taskbar - read up on GetSystemMetrics, it's probably there. Also, all of your individual objects in the dialog will remain where they are relative to 0,0 and may need to be resized. They can have MoveWindow called on them as well, by default they are derived from CWnd.
Hope this helps.
Christian
#include "std_disclaimer.h"
|
|
|
|
|
If I have an EXCEL file and I want the VISUAL C program to read data from that EXCEL file....Do you know how to do it?........I have tried the function fopen but they said I put the source code at the wrong function or something like that do you have any idea?
Thank you
|
|
|
|
|
Have you tried using the ODBC Excel Driver found under System DSN. At least it is there on my machine, I believe from the instalation of VC++. You should then be able to access like a database using CRecordSet derived class.
Michael Martin
Pegasystems Pty Ltd
Australia
martm@pegasystems.com
+61 413-004-018
|
|
|
|
|
any one now about how to implement buffering inaudio files.
cnu..a.
|
|
|
|
|
I have an OpenGL application app based on MFC. I have a requirement that I need to redraw the whole scene every second(some sort of animation). When I use the standard method of invalidating the client area every second, the CPU usage is very high and my app does not respond to any other commands.
Can someone suggest any better ideas?
Thanks
|
|
|
|
|
Only redraw the scene when something changes.
If you still need a frame every second, do a ::BitBlt() each second.
Michael S. Scherotter
Lead Software Architect
Tartus Development, Inc.
|
|
|
|
|
I tried defining an entry in the Accelerator table (CTRL+ALT+Z) and attaching it to the ID of a button. That didn't seem to work, cuz nothing happens when i press the key combo.
I would appreciate any help.
Thank you.
|
|
|
|
|
Never mind.
I just answered my own question.
For those who are interested, use RegisterHotKey() along with WM_HOTKEY message.
Works like a charm.
|
|
|
|
|
I enumerate the encoders registered on my computer(such as:Cinepak Codec by Radius, MJPEG Compressor,DivXMPEG-4 Fast-Motion...).Then how can I select one of them (Such as DivXFast-Motion) to compress the timeline using DirectShow filters?
Note:
These encoder have the same CLSID(CLSID_AVICo),only FccHandler and FridenlyName are different.How to select one of them?
Thanks!
|
|
|
|
|
is there any way to get the local time of your computer without using time_t of time.h?
|
|
|
|
|
No solution friend.
You will have to give up using time_t and start using Win32 SDK calls
these revolve around SYSTEMTIME structure and functions are GetSystemTime GetLocalTime.
|
|
|
|
|
thank you very much i will try that!
|
|
|
|
|
I wanna run an exe file from my software that is coded in VC++... Is that possible???? If yes can someone tell how??
Thanx....
|
|
|
|
|
_spawn works for me. Or WinExec. Or CreateProcess. Or use the help system...
|
|
|
|
|
ShellExecute can also be used.
- David Gevert (don't feel like logging in.)
|
|
|
|
|
Search as I may, I cannot find how to set a selection in a clistctrl from within code ( as in preseting a selection when the control is first populated ).
Also, I notice that whenever the dialog bar containing the list control is significantly moved ( un/docked, un/hidden ) the highlighted selection disappears.
Can anyone tell me how to handle these things?
I imagine they're fairly simple.
Thanks in advance.
|
|
|
|
|
To set the selection: ListView_SetItemState ( hwndYourList, nIndexToSelect, LVIS_SELECTED, LVIS_SELECTED );
You can add LVIS_FOCUSED to the flags to set the focus rectangle to the item as well.
--Mike--
http://home.inreach.com/mdunn/
#include "buffy_sig"
|
|
|
|