|
Hello, the codegurus around the world.;)
Fisrt of all, we are talking about the initalization of the string
in ComboBox.
And, OnInitDialog() in the parent dialog of ComboBox is best location
to do that.
Second, the location after DoModal() means that ChildDlg will disapper
since ChildDlg is the modal dialog like the message box.
This means that as long as ChildDlg is opened (DoModal still works),
we can add the new strings to this ComboBox inside or outside this dialog
as long as we can get the right CWnd of ComboBox.
Have a nice day!
-Masaaki Onishi-
|
|
|
|
|
Hi All, just a quick one - How can I change the font type and size that is used to display text in a combo box? At the moment my MDI App has one located in the MainFrame toolbar, but because the Arial font looks so pants its made my app look as though its been designed for Windows 3.x. Please help make my app look better,
Cheers Guys,
Alan.
"When I left you I was but the learner, now I am the Master" - Darth Vader
|
|
|
|
|
Just as with any other window:
<br />
void CWnd::SetFont( CFont* pFont, BOOL bRedraw = TRUE );<br />
I vote pro drink
|
|
|
|
|
Thanks for the response, however, I have inevitably reached a problem and my efforts have gone to no avail, please help. This is the code that has resulted from my patheticness in an attempt to get it going :
int CMainFrame::OnCreate(etc..)
stdFont.CreateFont(25,12,10,10,FW_THIN,FALSE,FALSE,FALSE,ANSI_CHARSET,OUT_OUTLINE_PRECIS,CLIP_DEFAULT_PRECIS,PROOF_QUALITY,0,"Times New Roman");
SetFont(&stdFont, TRUE);
Can you see where I`m going wrong with this? I`ve tried different values for the third and forth arguments, but the combo box still uses the same crappy font to display the strings!!! Also I have checked the return value of the CreateFont function and its 1, so it must be doing something? Any advice on my failings would be hugely welcomed.
Thanks again,
Alan.
"When I left you I was but the learner, now I am the Master" - Darth Vader
|
|
|
|
|
Is stdFont defined locally to the OnCreate function, or is a member variable? If it's defined locally, then when OnCreate finishes, the CFont object is destroyed, so you end up with the crappy default font. I don't know if this is the problem, but I know I've done this a lot of times!
------------------------
Derek Waters
derek@lj-oz.com
|
|
|
|
|
I found the answer, at last. I had been changing the MainFrame's standard font, and it was not being reflected in the combo box. As soon as I changed my code to m_ctlCombo.SetFont(&stdFont, TRUE), it worked! amazing! Many thanks to those of you who offered their advice on this, I very much appreciate it.
Cheers,
Alan.
"When I left you I was but the learner, now I am the Master" - Darth Vader
|
|
|
|
|
Here's some code for changing the font in a combobox...
LOGFONT lf = { 0 };
(void)lstrcpy( lf.lfFaceName, _T("MS Sans Serif") );
lf.lfHeight = -MulDiv( 10, GetDeviceCaps( GetDC()->m_hDC, LOGPIXELSY ), 72 );
VERIFY( m_font.CreateFontIndirect( &lf ) );
m_ctlCombo.SetFont( &m_font );
Best regards,
Mark
www.mjsoft.co.uk
|
|
|
|
|
Hi
I'm engaged in a project involving writting c code to solve the towers of hanoi problem as fast as possible. My goal is to be able to solve it with 30 rings in 1 second. Does anyone know of specific compiler command line switches to compile something to run faster or any good tutorials to assembler?
Zach
|
|
|
|
|
I believe that optimise for size actually results in faster code a lot of the time. Look up /O switches in MSDN for the full list of available switch options.
The John Robbins book 'Debugging Applications' by M$ Press has an assembler section that is quite good, but as he says, it is usually doubtful that you'd outdo the compiler nowadays.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
I use the optimize for speed option most of time and I find that it also reduces the size considerably. I have run into optimizer bugs many times with heavy floating point code though so I have learned to be careful.
|
|
|
|
|
The Towers of Hanoi problem is recursive - make sure you've implemented it properly, then optimise for size. A key optimisation might be taking the invariant out of your tight inner loops.
--
Andrew.
|
|
|
|
|
Hey Guys
I am totally stuck i have a structure that is working fine of 3 TCHAR arrays but as soon as i add a 4th TCHAR array the structure causes the program to crash has anyonegot any ideas.
This is the Structure
struct CertificateNames
{
TCHAR sCommonName[STRING_LENGTH];
TCHAR sIssuerName[STRING_LENGTH];
TCHAR sFriendlyName[STRING_LENGTH];
};
The only thing i can think is that there is a set size for a structure.
STRING_LENGTH = 256
Cheers Guys
Peter
|
|
|
|
|
You're obviously able to create a structure of four TCHAR's, you need to show us some code where it crashes to try and fix the problem.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
This is the Structure
struct CertificateNames
{
CERT_INFO CertID;
TCHAR sCommonName[STRING_LENGTH];
TCHAR sIssuerName[STRING_LENGTH];
TCHAR sFriendlyName[STRING_LENGTH];
};
As for what happens to it i only write values into the string arrays.
Cheers
Peter
|
|
|
|
|
given that a CERT_INFO structure has variable size, have you tried putting it last in the structure ? Having still not seen your code, I'm guessing you're writing in the wrong spot somewhere, and given that the size of CERT_INFO can change by the size of rgExtension, it seems to make sense to me to put it at the end.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
|
|
|
|
|
Hey Christian
The problem happens even with out the CERT_INFO structure (which i have now removed anyway). It seems i can add anything else to the structure except another TCHAR array. As for the code where it is used the reason i haven't given you any is it literally is passed into a function and then data written into the string. Anyway this is one of the functions.
bool CCrypto::GetSubjectNameFromCert(PCCERT_CONTEXT pCertificate, CertificateNames *CertInfoStruct)//(PCCERT_CONTEXT pCertificate, TCHAR *sSignerName)
{
OSVERSIONINFO OSVersion;
GetVersionEx(&OSVersion);
SYSTEMTIME ExpireDateCert;
FILETIME ExpireDateCertUTC;
if(OSVersion.dwPlatformId == 4 && OSVersion.dwMinorVersion == 10)
{
CERT_NAME_BLOB CertSubjectNameBlob;
CERT_NAME_BLOB CertIssuerNameBlob;
TCHAR sCertificateName[BUFFER_LENGTH];
DWORD dwSizeOfsCertificateName = sizeof(sCertificateName);
TCHAR sCertificateCommonName[BUFFER_LENGTH];
bool bQuoteFlag = FALSE;
CertSubjectNameBlob = pCertificate->pCertInfo->Subject;
CertIssuerNameBlob = pCertificate->pCertInfo->Issuer;
CertNameToStr(X509_ASN_ENCODING, &CertSubjectNameBlob, CERT_X500_NAME_STR, sCertificateName, dwSizeOfsCertificateName);
for(int i = 0; i < BUFFER_LENGTH; i++)
{
if(sCertificateName[i] == 'C')
{
if(sCertificateName[++i] == 'N')
{
if(sCertificateName[++i] == '=')
{
++i;
for(int y = i, d = 0; y < BUFFER_LENGTH; y++, d++)
{
if(sCertificateName[y] == '"')
{
if(bQuoteFlag == TRUE)
{
bQuoteFlag = FALSE;
}
else
{
bQuoteFlag = TRUE;
}
}
if(sCertificateName[y] == ',' && bQuoteFlag == FALSE)
{
CertInfoStruct->sCommonName[d] = NULL;//sCertificateCommonName[d] = NULL;
break;
}
else
{
CertInfoStruct->sCommonName[d] = sCertificateName[y]; //sCertificateCommonName[d] = sCertificateName[y];
}
}
}
}
}
}
delete &CertSubjectNameBlob;
_strset(&sCertificateName[0], NULL);
CertNameToStr(X509_ASN_ENCODING, &CertIssuerNameBlob, CERT_X500_NAME_STR, sCertificateName, dwSizeOfsCertificateName);
for(int k = 0; k < BUFFER_LENGTH; k++)
{
if(sCertificateName[k] == 'C')
{
if(sCertificateName[++k] == 'N')
{
if(sCertificateName[++k] == '=')
{
++k;
for(int g = k, h = 0; g < BUFFER_LENGTH; g++, h++)
{
if(sCertificateName[g] == '"')
{
if(bQuoteFlag == TRUE)
{
bQuoteFlag = FALSE;
}
else
{
bQuoteFlag = TRUE;
}
}
if(sCertificateName[g] == ',' && bQuoteFlag == FALSE)
{
CertInfoStruct->sIssuerName[h] = NULL;//sCertificateCommonName[d] = NULL;
break;
}
else
{
CertInfoStruct->sIssuerName[h] = sCertificateName[g]; //sCertificateCommonName[d] = sCertificateName[y];
}
}
}
}
}
}
delete &CertIssuerNameBlob;
}
else
{
CertGetNameString(pCertificate, CERT_NAME_SIMPLE_DISPLAY_TYPE, 0, NULL, CertInfoStruct->sCommonName, STRING_LENGTH);
CertGetNameString(pCertificate, CERT_NAME_SIMPLE_DISPLAY_TYPE, CERT_NAME_ISSUER_FLAG, NULL, CertInfoStruct->sIssuerName, STRING_LENGTH);
CertGetNameString(pCertificate, CERT_NAME_FRIENDLY_DISPLAY_TYPE, CERT_NAME_ISSUER_FLAG, NULL, CertInfoStruct->sFriendlyName, STRING_LENGTH);
ExpireDateCertUTC = pCertificate->pCertInfo->NotAfter;
FileTimeToSystemTime(&ExpireDateCertUTC, &ExpireDateCert);
//GetDateFormat(NULL, 0, &ExpireDateCert, "MMM dd',' yyyy", CertInfoStruct->sDateCertExpires, STRING_LENGTH);
}
return 0;
}
|
|
|
|
|
The problem is the structure seems to cause the problem on initalisation not when being passed or used in functions.
Peter
|
|
|
|
|
You can test this - you can write a constructor for a struct. Do that and initialise the values to something sensible, then try creating an instance of the struct and display them.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
TCHAR are used for Unicode systems, this is a macro that allows your code to be compiled in both ANSI and UNICODE
if you are compiling in ANSI, then use char instead
if you are using UNICODE then when comparing it against other chars you need to qualify the char with the _T macro
e.g.
change
if(sCertificateName[k] == 'C')
to
if(sCertificateName[k] == _T('C'))
|
|
|
|
|
I tried 20 TCHAR arrays of size 256 along with CERT_INFO in a simple diaglog program having the same struct in VC++ 7.0 and the program did not crash. This seems to be something else.
|
|
|
|
|
i've read it's possible to manipulate the browser from mfc app.
but how do i get my mfc app to execute an exe file?
is it possible to open an exe file and read into a buffer, and execute the file from there?
Or is it possible to point to an area in the exe file and start executing from there?
after all it was simple in c, u used the exec comand!
|
|
|
|
|
MFC adds no special support for executing prrgams, as it does not restrict any method to do it (which means you can still use your exec() command if that suits your needs).
There's no easy way to get an exe into a buffer and execute it from there; but probably you won't have such a special need.
There are a number of APIs that can execute programs, each with its pros and cons. Check these out:exec()
system()
ShellExecute()
CreateProcess()
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi,
How can I seek in a CMemFile?
It looks like the CMemFile::Seek function hangs my program...
Thanks in advance,
Erik Hammar
|
|
|
|
|
Alright All, I have a small brain teaser to do with Toolbars. I have managed to setup a toolbar successfully in the CMainFrame section of MDI App. Every time I open a file / create a new file it adds the relevant information to the combo box (i.e. the name of the file). Its then possible that I do some operations on these files, the names of these operations are then also recorded IN ORDER in the combo box. However, since I have an MDI app, and I`ve used the CMainFrame section to house the combo box, it is possible that the user mixes up the entries in the combo box that are associated with the different windows. I would like to be able to keep them separate, so that when the user clicks on a particular window, the combo box reflects the changes I`ve made to that one and that one only (and if I re-activated the other window it would re-display all the changes to that one etc.). I would appreciate any advice on this, even if it was to just tell me where to store the combo box control or how to switch back and forth different combo boxes as the different windows are activated.
Cheers again guys,
Alan.
"When I left you I was but the learner, now I am the Master" - Darth Vader
|
|
|
|
|
I would recommend keeping the list of changes you have made in the document object. Then wehn tyhe user switches document, (or toa different view), you can handle the OnSetActive of that view and populate the combo box in the toolbar. Something like:
void CMyView::OnSetActive(bool m_bActivate)
{
if (m_bActivate)
{
CComboBox* pCombo = &((CMainFrame*)(AfxGetApp()->m_pMainWnd))->m_ComboBox ;
pCombo->ResetContent() ;
}
}
Its a bit rough and done from memory so it may be a little bit buggy
Roger Allen
Sonork 100.10016
|
|
|
|
|