|
I'm calling this function about 25 times per second, I know the code is a bit of a mess but I'm just worried about the increasing memory problem. I have included ReleaseDC(hwnd, hdc); now and it has made a significant difference but I'm still losing a bit of memory! I can't actually get rid of the for loop because I'm using this to draw lines between each point on the graph.
Thanks for the help.
|
|
|
|
|
Try:
void function3 (HWND hwnd, <code>double& a[400]</code>, int iLength)
{
HDC hdc;
PAINTSTRUCT ps;
int i <code>= 0</code>;
hdc = GetDC(hwnd);
Rectangle(hdc, 0, 0, 400, 256);
MoveToEx(hdc, 0, 256, NULL);
for (i=1; i< 400; <code>i++</code>) <code>
{
<code>
<code>LineTo(hdc, i, (255 - static_cast<int>(a[i]));</code>
}
EndPaint (hwnd, &ps) ;
}
It may not solve all the memory issues, but may speed you up some and maybe ease it a little.
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
Thanks I have it fixed now, there was another part in my app where I was creating a colored pen over and over again using
hPen = CreatePen(PS_SOLID, 1, RGB(0, 0, 255));
and not deleting it when I was finished. Just stuck in
DeleteObject(hPen);
and it's all sorted now!
Thanks for the help,
Paddy
|
|
|
|
|
My product MemWatcher[^] will help identify if you're leaking resources.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I am using C++ Builder and want to create a window like the propertis windows in Visual Basic or the Object Inspector in C++ Builder. Thanks!
|
|
|
|
|
Hi All,
A brief about the prob I am facing. We have a dialog being displayed (has got property pages)... In one particular property page.. we have 2 radio buttons... (other controls not in question)... we display a dialog whenever the user tries to change the selection of the radio control. Say from "radio1" to "radio2"... It's basically a simple Yes/No question messagebox. If the the user selects "yes" the user is allowed to select the other radio button, otherwise not.
"radio1" is selected by default. User changes to radio2. after selection... dialog appears (asking for confirmation). If the user says "yes" then we continue as it is, otherwise we progra-matically restore the first radio controls state (selected=true) by setting m_nFirstRadio=1. this is the variable controlling the state of these two controls.
We are hadling the OnRadioButton() message handler for both of these controls.
Till now it works perfectly.
but when we change the property page to some other at runtime.. I don't know why.. but the message handler for the radioButton is being called (about 18 times). In effect displaying the conformation dialog about 18 times...
Any idea why this is happening??? I am not calling the OnRadioButton message handler manually. One more thing.. this happens only when the user selects "no".. thus we had to restore the state programatically.
Is there any rule as to when to use the radio button's member variable to change the state...
Regards,
Mohit
|
|
|
|
|
Your are already sitting on the answer.
Your change the state of the other radio buttons manually, therefore you generate
OnRadioButton messages.
As a workaround You could set a flag when You are changing the state of the buttons manually
and check for this flag in the OnRadioButton handler.
Yours,
Alois Kraus
|
|
|
|
|
Hi Alois,
But the message shoudl be generated only once if at all. Since I click on the radio button only once, and then say "no" in the confirmation dialog. So the state is restored. Below is the code in the handlers "Locked" and "UnLocked" both are radio buttons. m_nRadLocked controls the state.
Why the handler is being called 18 times.. and that too when I am changing to a different property page using the tab control.
Somebody told me that this is a BUG with VC++/MFC. And happens when we use AfxMessageBox/and radio buttons. But I really don't think so. So thats why I had mailed the forum.
property page looks somewhat like this:
/----------------------------------------\
| |
| O Locked O Unlocked |
| |
| some other controls ------ |
\----------------------------------------/
void CSDT12ConfigDCCPage::OnRadUnlocked()
{
UpdateData();
// If Board Admin State locked,
// We shoul not allow to change Admin State of Port to Unclocked state
if(((CSDT12ParentDialog*)m_pParent)->GetAdminState() == 1)
{
m_nRadLocked = 0;
UpdateData(FALSE);
}
}
void CSDT12ConfigDCCPage::OnRadLocked()
{
UpdateData();
/* this condition is to avoid the handler to be called un-neccesarily */
/* if this condition is not present.. dialog is called 18 times while */
/* changing property page to another */
if (m_nRadLocked == 0) /* Check if this msg handler is really being called*/
{
if (AfxMessageBox(IDS_SDT12_BOARD_LOCKED_WARNING,
MB_YESNO | MB_DEFBUTTON2 |MB_ICONQUESTION) == IDNO)
{
m_nRadLocked = 1;
UpdateData(FALSE);
}
}
}
Regards,
Mohit
|
|
|
|
|
HI
I have some buttons that I am linking to ShellExecutes, but in this program the parameters to some of the ShellExec are an unknown filename. Also, some of the files to Exec are unknown filenames.
I know the directory and extension of the files I want to exec, but the actual names of the files changes.
Also, there will only be max of one file of each extension to Exec.
If the file does not exist, I want the button to be greyed out.
Does anyone have any insight in how to go about any of this, or what functions to look at? Is there an "anything" character, or is FileFind someplace I should be looking?
Thanks!
|
|
|
|
|
just use ShellExecutes and "open" to "execute" file,windows can lookup register and find proper program to open it
use :
BOOL PathFileExists(
LPCTSTR pszPath
);
to test the does the fileexisted
I am seeking...
For what?
Why did you ask me for what? I don't know!
|
|
|
|
|
I have the following situation:
Class A:
{
public:
virtual void getValue (float& val) const
{val = 5.0f;}
virtual void getValue(bool& val) const
{ val = true;}
virtual void getValue(string& val) const
{ val= "abcd";}
}
class FloatA: public A
{
public:
virtual void getValue (float& val) const
{val = 10.0f;}
}
class BoolA: public A
{
public:
virtual void getValue (float& val) const
{val = true);
}
I figured out that calling the float function take 20 times time than the bool function !
Any idea ???
Is it the float type (it is happened also with double) ?
Is it the overloading order ?
|
|
|
|
|
bool was prodess as short int
process speed of float is slowly than int
I am seeking...
For what?
Why did you ask me for what? I don't know!
|
|
|
|
|
|
|
hi
i m makg a windows browser based applction with 2 panes :
left derived from CTreeView and right from CHtmlView.
iwant to access object of CHtml derived class from CleftView
can any hlp me out
|
|
|
|
|
Use their common ancestor (probably it's the MainFrame, or a ChildFrame for MDI apps)
A rock pile ceases to be a rock pile the moment a single man contemplates it, bearing within him the image of a Cathedral[^].
Antoine de Saint-Exupery (1900-1944)
|
|
|
|
|
This is the common case of the document view architecture. In the doc should the data-objects (very good for serialization) and with pointers/interfaces to them you get the data which you can disaply in the views.
PS: Editing and modifying functions are best implemented in the mainframe so EACH view can access them.
Try this @ home. (B&B)
|
|
|
|
|
use global pointer
I am seeking...
For what?
Why did you ask me for what? I don't know!
|
|
|
|
|
hi,
Do it via your splitter wnd
CMainFrame::GetInfo()
{
CSplitterWnd* pSplitter = &m_wndSplitter;
ASSERT_VALID( pSplitter );
CWnd *pPaneWnd = pSplitter->GetPane(0, 0);
CLeftView* pTreeView = static_cast<cleftview*>(pPaneWnd);
ASSERT_VALID( pTreeView );
ASSERT_KINDOF( CTreeView, pTreeView );
HTREEITEM hItem;
hItem = pTreeView->GetTreeCtrl().GetSelectedItem();
or
CWnd *pPaneWndTwo = pSplitter->GetPane(0, 1);
CHtmlView* pHtmlView = static_cast<chtmlview*>(pPaneWndTwo);
ASSERT_VALID( pHtmlView );
ASSERT_KINDOF( CHtmlView, pHtmlView );
}
include your HtmlView.h in your file where to call it
hope it helps,
|
|
|
|
|
hi
u got it exactly right,thts wht i wanted to do.
thx for ur help
bye
|
|
|
|
|
Hi,
Is there anyway to increase the dialog border width?
Regards
Neha
|
|
|
|
|
Use the MoveWindow function
Ex. MoveWindow(&myRect, TRUE);
|
|
|
|
|
You can do that in a number of ways.
1) you can use WM_NCCALCSIZE to recalculate the size of the client area for your window or dialog, by reducing the default size of your client area that will increase the size of the borders.
2) You can handle the WM_NCHITTEST yourself, and return the HTRIGHT, HTBOTTOM etc for all of the border cases, and increase the dimensions that count as the border. This will make all of the other default message handlers act as if the border is wider.
In either of these cases I would handle the WM_NCPAINT message in order to paint and extend the appearance of hte width of the new border that you create.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
|
Hi,
My program can now uninstall itself with a "-u" argument; and it'd invoked by CP->Add/Remove Programs just fine.
My question is, what is the proper way to delete my uninstall app's file itself? I can't delete it because it's locked when i'm running the app.
My only thought is to use HKLM/Software/Microsoft/Windows/CurrentVersion/RunOnce, and a cmd entry to delete the file, but this isn't really very smart. Surely there's a better way? How does installshield do it?
Thanks
Jon
#include <beer.h>
|
|
|
|