|
Well,... I "screwed up" again I guess I was comparing apples and oranges. The qsort method used the strcmp (C-runtime) function to compare strings. I used CString's operator> method to compare. Both give the same answer, but the CString was much faster. I didn't bother replacing the STL sort code with the strcmp code, because I'm sure it would be slower than qsort's.
Sorry for the misleading results!
Derek
|
|
|
|
|
Hello,
I just converted an article at the "other" site (http://www.codeguru.com/listview/VirtualListControl.html) from CArray to std:vector. The performance increased 5 times! The only section that I didn't like was the column sorting method. It uses the qsort() function to sort the columns. It seems there would be a more elegant (STL) method of doing this. There is a class defined for a row of data similar to this (shortened for clarity):
class CRowData {
CString col1;
int col2;
}
The qsort function calls the appropriate comparison function to sort on the desired member. It seems like there should be a way to do this using the STL. I would like to expand this example to include sorting on more than two columns as well.
Any ideas?
Thanks,
Derek
Doble Engineering
|
|
|
|
|
Where is the flag that I can set in MS Visual C++ that will allow me to have an instance of MS Visual C++ open, then double click a .dsw in Windows Explorer and have that workspace open in another instance of MS Visual C++? I know I have something set somewhere that allows this, I just cannot remember. Any help?
Roger Printy
Software Engineer
TeraNex
Orlando, FL
|
|
|
|
|
Is there a way using the C++ automation to find out the location of the project/file in the SourceSafe?
The only solution that I see for now is to find out the path of the project and than to parse the .dsp or .dsw file to find out the path of the project in the SourceSafe.
I would like to do this without parsing the .dsp or .dsw file...
Thanks.
Rasstislav
|
|
|
|
|
when trying to click on a listbox created in runtime over an edit control in a formview, the existing edit control under the listbox control gets a focus. so i can't select an item in a listbox. somebody help me...
by peng-you.
|
|
|
|
|
hmmmm
try either setting the z-order of the listbox to be in front of the edit control ... maybe destry the edit control ... disable it ... or use a combobox that allows the user to type stuff into the list control portfion and add some custom behaviour to stop the item being added to the list
---
"every year we invent better idiot proof systems and every year they invent better idiots"
|
|
|
|
|
How can I make my CFileDialog to accept directories and return the full path name of the directory. Something like what I get when I select File / New option in the MSDEV IDE and click on the "..." button next to Location Edit box ??
Sudha Shriram
|
|
|
|
|
You don't need CFileDialog for that. Use SHBrowseForFolder instead.
Tomasz Sowinski -- http://www.shooltz.com.pl
|
|
|
|
|
Hi,
If you look on the menu of InternetExplorer:
FILE | SEND -> here you get a popup menu
i need to do the same but do not know how
m_menu.LoadMenu(IDR_MENU1);
SetMenu(&m_menu);
CMenu* pContextMenu;
//Get sub menu - index 0
pContextMenu = m_menu.GetSubMenu(0);
pContextMenu->AppendMenu(MF_STRING | MF_POPUP, ID_MENU_ADD, "NEW ITEM");
pContextMenu->AppendMenu(MF_STRING | MF_CHECKED, 5001, "NEW ITEM2");
this code will add two new items under the first position in my IDR_MENU1.
How can add new items to position "NEW ITEM2" ?
thank you
|
|
|
|
|
In your dialog editor, you do this by checking 'pop-up' for the item, then you can build a menu underneath it. I'm sure it can be done programatically, from memory by adding a menu to another, but I forget the details.
Christian
#include "std_disclaimer.h"
|
|
|
|
|
it can be done dynamically. i did it with the following code. (IDR_MENU1 - has only captions of my menu)
m_menu.LoadMenu(IDR_MENU1);
SetMenu(&m_menu);
CMenu* pContextMenu;
CMenu pPopMenu;
//Get sub menu - index 0
pContextMenu = m_menu.GetSubMenu(0);
pPopMenu.CreatePopupMenu ();
pPopMenu.AppendMenu (MF_STRING, 5001, "shortcut to desktop");
pPopMenu.AppendMenu (MF_STRING, 5001, "email");
pContextMenu->AppendMenu(MF_POPUP , (UINT) pPopMenu.m_hMenu , "SEND");
thanks
|
|
|
|
|
hi there
i want add an activex control into my project.
its a little bit complicated to explain.
on the start of my program i start all of my windows and minimized them to 0,0,1,1 most of them are CDialog
some CFrame... i dont use mfc ... only a very little bit.
now i want to insert a activex same way. start "minimized" without data. this works. but if i want to insert data. then i hang up.
how can i insert an activex "without mfc" ... or only little little bit of mfc ...
thx
|
|
|
|
|
Hi, I'm working with a composite control in Visual C++...
Among other things I have a button on the dialog..
The problem is that I can't get it to react on me pressing the enterbutton.
I've tried overloading the pretranslatormethod but that doesnt work so good....
HELP
|
|
|
|
|
Assign the IDOK identifier.
(By default the OK button captures the [Enter] key)
AEB
|
|
|
|
|
It doesnt work...I have tried...try it using a composite control...using a plain dialog..it works
/Pierre
|
|
|
|
|
Does anyone know how to pass parameters into an sql command?
Either prompting or just straight in?
Sample code or KB would be very useful.
Thankyou verymuch
Richard.:confused
|
|
|
|
|
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"
|
|
|
|