|
Oh, I am still working with VC++ 6.0 (mfc42) and cannot help you. And I have a problem, too. Could you do me a favor?
When I use winsock (CSockect e.g.) to recieve the message of websites by sending "Get ...", majority are no problem but others can't work. I opened these ones in IE, They displayed a Security Alert messagebox with "Information you exchange with this site cannot be viewed or changed by others. However, there is a problem with the site's security certificate."
Why I recieve nothing under this condition?
|
|
|
|
|
I have tried using the select font dialog box to select a font for an edit control and it doesn't work. The edit control goes into the default font. Here's the code i used:
void CDocBar::InitFontDlg()
{
CFont myfont;
LOGFONT lf;
CFontDialog dlgChooseFont;
COLORREF g_rgbText = RGB(0, 0, 0);
CEdit *editControl;
//GetObject(myfont.Detach(), sizeof(LOGFONT), &lf);
dlgChooseFont.m_cf.lpLogFont = &lf;
dlgChooseFont.m_cf.rgbColors = g_rgbText;
if (dlgChooseFont.DoModal() == IDOK)
{
myfont.CreateFontIndirect(dlgChooseFont.m_cf.lpLogFont);
g_rgbText = dlgChooseFont.m_cf.rgbColors;
editControl = (CEdit *) GetDlgItem(IDD_EDIT1);
editControl->SetFont(&myfont, TRUE);
}
}
What could be wrong? I have little experience with fonts.
-- Steve
|
|
|
|
|
It's a scope-problem - make myfont member of CDocBar and I'm pretty sure it'll work.
Regards,
Michael Mogensen, mm it-consult dk.
|
|
|
|
|
Thanks! I hate when these kinds of problems are caused by such a small thing. It works great!
-- Steve
|
|
|
|
|
I have built a program in using VC++ 6.0 that will parse out the URL's from an AOL .pfc(personal filling cabient) file. The .pfc is full of garbage(terminators, little boxes kinda looks like encryption, misc chars, and URL's) The program works just fine on most .pfc files. The problem Im having with some .pfc files are that the program will not read the entire file. I have reason to believe that my troubles lie in the eof(end of file) terminating condition. Here is the code that reads in the file char by char adding it to a string:
if(! inStream.eof()) {<br />
<br />
if(! iscntrl(cSymbol))<br />
m_strBeforeParse += (CString)cSymbol;<br />
<br />
inStream.get(cSymbol);<br />
}
For some reason the eof function is returning "true" when it reaches a certain part of the file. This certain part of the file is the little boxes in the file that I described earlier as what I thought looked like encyrption. If I erase these little boxes, I can read whole filwe just fine. If anyone has any ideas Id be greatful to hear them.
|
|
|
|
|
how are you opening the file? What flags do you pass in to the file constructor/open code?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
Santa Cruz Networks
|
|
|
|
|
I've had the same problem before (just dealt with it today in fact). The little boxes you see are non-printing ascii characters. When I ran into the problem, the char was decimal 26, hex 1A. You are reading a binary file as a text file, and that's why you are having a problem. If you read the file as binary, you won't have the EOF problem, you'll just have to change your code a little bit.
--Dean
|
|
|
|
|
Thank's Dean
-Rocky
|
|
|
|
|
Just wondering if someone can point to any tutorial onCallback Functions
with some good examples
|
|
|
|
|
It is a mechanism by which you can call another static function by using its function pointer . Very useful when u do a layered class architecture . U could pass data from one class to another and provide filtering too.
|
|
|
|
|
http://www.codeproject.com/cpp/callbacks.asp?target=callback%7Cmfc
|
|
|
|
|
Dynamic dialog is a dialog of which controls
can be created or removed manually depends on the situation.
It is easy to make a dynamic modaless dialog as follows.
////////////////
CDialog *menu;
menu = new CDialog;
menu->Create(IDD_MY_BLANK_DIALOG, this);
// add a edit control if IsEdit is true
if(IsEdit) {
CEdit* pEdit = new CEdit();
RECT rctEdit = {5, 5, 100, 30};
pEdit->Create(WS_VISIBLE | WS_CHILD | WS_TABSTOP, rctEdit,
FromHandle(menu->m_hWnd), 1100);
}
// add a button control if IsBtn is true
if(IsBtn) {
CButton* pButton = new CButton();
RECT rctButton = {5, 35, 100, 60};
pButton->Create(_T("Button"), WS_VISIBLE | WS_CHILD | WS_TABSTOP, rctButton,
FromHandle(menu->m_hWnd), 1101);
}
menu->ShowWindow(SW_SHOW);
///////////////
But I want to make a dynamic modal dialog.
I heard about the InitModalIndirect function but it is somewhat complex to use.
I want a compact code.
Is there any simple method like an above code?
Thanks.
|
|
|
|
|
well...
When you call the DoModal function you must have the dialog created, then just before to call DoModal, you can add all the controls you want...
Hope this helps...
|
|
|
|
|
That's exactly what I want.
But the question is how to implement it?
I tried many ways, but I failed because of lack of knowledge about creating controls
in blank dialog.
Could you show me an example which is really working?
The important thing is that it should be a modal dialog.
Thanks.
|
|
|
|
|
In order to create dynamically a combobox, you should do this:
<br />
CRect r;<br />
<br />
if (this->m_ccbParametritzacio.GetSafeHwnd() == NULL)<br />
{<br />
this->m_ccbParametritzacio.Create(WS_CHILD | WS_VSCROLL | WS_HSCROLL | CBS_DROPDOWNLIST, r, this, UNIQUE_ID);<br />
<br />
this->m_ccbParametritzacio.SetFont(this->GetFont());<br />
}
NOTE0:
you should change "this->" for the parent dialog... (this is only supposed I've not tried it)
NOTE1:
there was an article referring on this topic here in CP or in codeguru (I don't remember exactly...)
NOTE2:
I recommend you to use a derived listctrl with buttons, comboboxes, editboxes... in order to do what you are searching for because this control is extendable and if there are lots of controls to be created dynamically you'll be able to go through them using the implemented scrollbars, and moreover you'll avoid to recalculate the place where to put the control and where to put the text referred to the same control...
Hope this helps...
|
|
|
|
|
Actually, I had found an article exactly matched to this topic before I post
my first question. In that article, one can use similar method like dynamic
modaless dialog to make a dynamic modal dialog by including supplied codes.
Spending many times, I was finding other method
to do that without the code.
I decided to use that code and now it works well.
If you have interests in this article,
please refer this.
http://www.codeproject.com/dialog/dynamicdialog.asp?target=dynamic%7Cdialog%7Cmodal
|
|
|
|
|
I have a problem with the CImage::StretchBlt Function! I made a little application, based on the "SimpleImage" -Sample Application from Microsoft.
I tryed to stretch a picture to the screen (dynamic..)
in the OnPaint() Function i have the following line:
m_imgOriginal.StretchBlt(dc,0,0,m_imgOriginal.GetWidth()*dFactor, m_imgOriginal.GetHeight()*dFactor, SRCCOPY);
dFactor is a Factor, calculated earlier.
so the problem is, when dFactor is higher than 1 everithing looks fine, the picture is stretched properly. but when the factor is below 1, the picture looks very poor and distorted! is there a sloution to the problem?
is it possible to make a CImage-Picture smaller at all without distorting it??
thanx for any input!!
|
|
|
|
|
Try doing this ,
SetStretchBltMode(destDC,HALFTONE);
where destDC is teh destination DC
|
|
|
|
|
very cool! now it works! thanx a lot!
|
|
|
|
|
Is there a function for retreiving a random integer lying in the range from one integer to another? I'm using Win32...
THanks in advance.
|
|
|
|
|
see rand() and srand(..)
srand(-1);
int v = (rand() % (low + high)) + low;
To vote with no response is to follow the way of the coward.
|
|
|
|
|
Check out this page -- shows a better way to get your random numbers. When you use modular arithmetic, you focus on the low-order bits that aren't as "random" as the high-order ones.
The page shows many examples of how to get a random number (int or floating point) in a given range.
--Dean
|
|
|
|
|
No, but you can get a pseudo-random number with srand() and rand().
|
|
|
|
|
See article by:
Stephen K. Park and Keith W. Miller.
RANDOM NUMBER GENERATORS: GOOD ONES ARE HARD TO FIND.
Communications of the ACM, New York, NY.,October 1988 p.1192
Just trying to keep the forces of entropy at bay
|
|
|
|
|
#define GetRandom(min, max) ((rand() % (int)(((max) + 1) - (min))) + (min)) //get a random number between min and max
Remember something like srand(GetTickCount()); first...
- Anders
Money talks, but all mine ever says is "Goodbye!"
|
|
|
|