|
Greetings,
I have been stuck with this problem for a while and I cannot see what I'm doing wrong. I'd be grateful is anyone could point me in the right direction.
I have a class whose constructor is :
CMyClass::CMyClass() : CPropertyPage(CMyClass::IDD)
{
some stuff
}
Then I have,
BOOL CMyClass::OnSetActive()
{
static doneInit = FALSE;
BOOL bResult = CPropertyPage::OnSetActive();
if (!doneInit)
{
doneInit = TRUE;
if(m_WindowOut)
delete m_WindowOut;
m_WindowOut= new CWnd;
CRect rect1;
GetDlgItem(IDC_PROCESSED_WAVE)->GetWindowRect(rect1);
ScreenToClient(rect1);
m_WindowOut->CreateEx(WS_EX_CLIENTEDGE|WS_EX_STATICEDGE, AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW),NULL,WS_CHILD|WS_VISIBLE,
rect1,this, 1234);
CDialog::OnInitDialog();
}
return bResult;
}
where IDC_PROCESSED_WAVE is a picture control that I have on my dialog and
is where I would like to do the drawing and m_WindowOut is defined in
MyClass.h as public and as CWnd* m_WindowOut;
Finally the offending code:
void CMyClass::OnPaint()
{
int amp;
//CDialog::OnPaint();
CPaintDC dc(m_WindowOut);
CPen* pOldPen;
CPen pen(PS_SOLID,0,RGB(0,255,0));
pOldPen = dc.SelectObject(&pen);
CRect rcClient;
m_WindowOut->GetClientRect(&rcClient);
for(int i = 0; i < rcClient.Width(); ++i){
amp = (rand()% 15)% (rcClient.Height() / 2);
dc.MoveTo (rcClient.left + i, rcClient.top + (rcClient.Height()/2) -
amp);
dc.LineTo (rcClient.left + i, rcClient.top + (rcClient.Height()/2) +
amp);
dc.SelectObject(pOldPen);
m_WindowOut->Invalidate(TRUE);
}
// TODO: Add your message handler code here
// Do not call CPropertyPage::OnPaint() for painting messages
CDialog::OnPaint();
}
Unfortunately, nothing is drawn on my picture control and I don't have a
clue why. Please help if you can.
Regards
Rick
|
|
|
|
|
Hi, I tried to change the font of a label using SelectObject but it don't work. The SelectObject works if I use TextOut(...). But for label or edit, I use SetDlgItemText(..). So how to change the fonts used for edit/label or is there anything that I did it wrongly. Thanks.
code that I use
========================
HDC hDC = GetDC();
hFont = CreateFont(....)
HFONT hFontOld = (HFONT)SelectObject( hDC, hFont);
TextOut(....)
DelectObject(hFont)
SelectObject(hDC, hFontOld);
|
|
|
|
|
i think this way could work:
overwrite or go into InitDialog (WM_INITDIALOG)
and set here the font for the label.
I hope that is correct, because it's only a part of 16-bit-code-application (MFC). I believe IDC_ErrorA was a Label.
//define at the top of your cpp-file
CFont m_biggerFont; //must be are here, global in View for Paint()
void Cxx_View::OnInitialUpdate()
{
LOGFONT logfont;
CRect rect; // get edit control size
GetDlgItem(IDC_ErrorA)->GetWindowRect(&rect);
ScreenToClient(&rect); // in parent coordinate
memset(&logfont, 0, sizeof(logfont));
logfont.lfHeight = int ((rect.bottom-rect.top));
logfont.lfWeight = FW_BOLD;
switch(FontType)
{
case 0: strcpy(logfont.lfFaceName, "MS Sans Serif");break;
default: strcpy(logfont.lfFaceName, "MS Sans Serif");
}
VERIFY(m_biggerFont.CreateFontIndirect(&logfont));
GetDlgItem(IDC_BigA)->SetFont(&m_biggerFont,TRUE);
GetDlgItem(IDC_BigA)->UpdateWindow();
...
}
|
|
|
|
|
Hi!
I want to get string variables from a text file(.txt) how is this done? I want to be able to choose specific strings in the file when I know how the text file was formated.
If there's a better way using data bases and that isn't too complicated, that could work too
Thanks
/Fredrik
|
|
|
|
|
Can anyone tell me if there is a way to include non-standard text characters in a regular titlebar?
I'm looking to add some superscript text in my applications main window titlebar.
Thanks!
Frank
|
|
|
|
|
When I upgraded to Access 2000 I got the unrecognizable database format error.
Following MS's instructions, I added
AfxGetModuleState()->m_dwVersion = 0x0601;
before I opened the database. Now I can open the database,
but I crash when I try to access it. I'm using mfc shared dll. Service pack 3.
Anything else I need?
Thanks
|
|
|
|
|
Hello everyone!!!
I have a collection of existing True Type Font Resource filenames(*.ttf). My task is to install those fonts from resource files. My available tool is Win32 API only just because I am using InstallShield 5.0 scripting language.
With available resources, for me, installation is two-step job: 1) Using AddFontResource method; 2) Insertion of proper font keys and values into the registry - font key = font face text; font key value = font resource filename.
The QUESTION is: given that my font has not been installed yet, how can I obtain font face text using ONLY resource file name as needed for key name in the registry.
Please, please, please HELP!!!
Thanks a bunch ahead.
Kirill Sherman.
Stahls' Inc.
|
|
|
|
|
I have a exception class which I would want to be catch by ref only, so I declare the copy constructor private.
However, VC++ 6 refuses to compile, giving me an error an error that the exception object cannot be thrown because of an inaccessible copy constructor.
But upon checking, the copy constructor is only called when the exception object is caught by value
eg
catch(MyExceptionClass e) // only this needs the copy constructor
{}
catch(MyExceptionClass &e) // this doesn't need the copy constructor
{}
So has anyone been able to ensure the exception object is to be catch by ref only, not value??
|
|
|
|
|
My tests (VC6 and Borland CPPB4) disagree with yours - the copy constructor is called for the catch declared as taking a reference.
For a function that takes a reference, it's true that the CC isn't called - the trick here is that the throw() operand causes a copy of its argument to be created.
Check out "C++ Exception Examples" in the MSDN.
|
|
|
|
|
How do I change the Single Document's name I mean the Caption of the program!
|
|
|
|
|
Try CDocument::SetTitle()
If you are doing this from the view class, you can call GetDocument()->SetTitle(_T("Whatever")); . (This assumes there _is_ a CDocument attached to the view - better code might check that GetDocument() doesn't return NULL).
|
|
|
|
|
http://home.socal.rr.com/samhobbs/VC/ChangeTitle.html
|
|
|
|
|
I have problems with normal, simple enabling and graying menu items.
Commands like:
AfxGetMainWnd()->GetMenu()->EnableMenuItem(ID_VIEW_TOOLBAR,MF_GRAYED|MF_BYCOMMAND);
or
AfxGetMainWnd()->GetMenu()->GetSubMenu(2)->EnableMenuItem(0,MF_GRAYED|MF_BYPOSITION);
or
AfxGetMainWnd()->GetMenu()->GetSubMenu(2)->EnableMenuItem(ID_VIEW_TOOLBAR,MF_GRAYED|MF_BYCOMMAND);
following with:
AfxGetMainWnd()->DrawMenuBar();
AfxGetMainWnd()->RedrawWindow();
didn't function (the items remained enabled), even though the Status of menu items has been changed (when I tried to call the some function for the second time, the return value (=previous state) was as I set it).
Noticable is, that command
AfxGetMainWnd()->GetMenu()->EnableMenuItem(0,MF_GRAYED|MF_BYPOSITION);
worked properly.
Could You help me with my problem, please?
Thank You very much...
|
|
|
|
|
I bet the UPDATE_COMMAND_UI mechanism is overriding your calls and re-enabling the menu items. Write UPDATE_COMMAND_UI handlers instead to disable the menu items; that's the "right" way to do it anyway.
|
|
|
|
|
Hi Everyone,
How do I display the data in a Microsoft Access Table with an MFC application?
Can I call up a table from Access for display directly?
If anyone knows, Please let me know.
Thanks in Advance!
Steve
|
|
|
|
|
Hi,
I have a MFC application that uses Microsoft Access tables.
The result of my program writes data into a Access database so at the end, I have a Table with the results.
I would like to know: How can I allow the user to save that RESULT TABLE where they SPECIFY the name of the table and the location of where to save it?
If anyone has any ideas, Please let me know.
Thanks in Advance
Steve
|
|
|
|
|
Hi,
how could i get two dialog bars docked like this:
_____________
| | |
| | |
| |---------|
|_|_________|
( ie. - i want the left dialogbar to take
all height available. )
/*
unless i don't call DockControlBar on bottom window
(but then it can't be resized anymore. )
i just always get the VC version
____________
| | |
| | |
|_|_________|
|___________|
*/
Thank you++
|
|
|
|
|
hi there
just a quicky - i need to obtain the hwnd of all the other currently running programms on order to send then WM_* messages
|
|
|
|
|
Try EnumWindows() . That should get you the hwnds for the top level windows of the desktop processes - you could also use EnumChildWindows() both for this and for getting child windows of the processes after you get their main windows.
|
|
|
|
|
You don't need to get their HWNDs, just call SendMessage() with HWND_BROADCAST as the first param.
|
|
|
|
|
TAHNKS ,you are great exactly what i needed
|
|
|
|
|
how to create a new .c file and .dsp file .dsw file and a .h file and a .rc file ? How to make sure these files are linked together for my application? Sorrie I am new to c++ programming. Thanks for helping
|
|
|
|
|
What you need to do is purchase Microsoft Visual C++ Version 6.0 ( maybe even 5.0 ) and then
all the fancy dsp files will be automatically constructed for you. And a small matter : if you are doing
c++ programming then there is not necessarily a .c file--instead a .cpp file ! Sorry if this sounds
expensive.
Dave
|
|
|
|
|
Hi,
Is there anyway that I can convert an int to a double without losing any of the data?
Thanks
|
|
|
|
|
what about (double)intvar
the precision of a double is 64 bits, that should be enough
|
|
|
|