|
Finally this solution works for me. What I did is
1. In ReadFile() - Read from different COM port. E.G Writing is done on COM1 and Reading is Done on COM2. As I was having only 1 COM Port . I installed Virtual Port Software on my machine and Paired COM1 and COM2
2. ReadFile() provided a buffer of exact size which I used in WriteFile () method.
|
|
|
|
|
Is there a method to start a child window ( in a MDI application ) without get a flikering ? I try in this way :
void CMainFrame::OnOpenChildWindow()
{
POSITION pos = theApp.GetFirstDocTemplatePosition();
CMultiDocTemplate* pDocTemplate = (CMultiDocTemplate*)theApp.GetNextDocTemplate(pos);
pDocTemplate = (CMultiDocTemplate*)theApp.GetNextDocTemplate(pos);
pDocTemplate->OpenDocumentFile(NULL);
pChild = (CMDIChildWnd*)MDIGetActive();
if(pChild)MDIMaximize(pChild);
}
but because I have a little code ( that takes time ) in OnNewDocument() , I see child window that is opening in restore state , and after that child window is maximized ...
|
|
|
|
|
You might want to try the OnCreate message for your child window instead. I think you can adjust settings, Eg., window position, state, etc, in this message so that the window opens maximized.
Chris Meech
I am Canadian. [heard in a local bar]
In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]
|
|
|
|
|
Hi all
I am creating an application in win32 api(c++ not MFC) and when i resize window the portion of non affected window is also get redrawn that causes flicker effect.so can anyone inform me how to handle WM_PAINT message so that only affected part of window will redraw??
Its urgent... Thank you in advance...
--
Thanks and Regards
Hemant metalia
hemant_metalia@yahoo.com
|
|
|
|
|
Hi,
I see three factors here:
1.
the repaint job holds a region, only things inside the region needs repainting, so your painting code could take that into account; however, the repaint region often is larger than necessary, so this may well be insufficient.
2.
improving the paint code performance is always a good idea, it also reduces the disturbance, hence flicker, you would notice. It does not avoid it, just makes it less annoying.
3.
the real solution is using double-buffering, where the actual painting happens in a memory-based buffer, then that buffer gets painted in one swoop to the screen, without erasing the current content. You'll have to Google for details in C++, I'm not able to provide you any code as I work mostly in C#.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
As Luc said take a look at double buffering, this code project article might help.
But in general terms you will need to modifiy you paint routine to do all your drawing to a compatible memDC, once drawing is complete you'll need to blit the area you require to the screen DC.
|
|
|
|
|
What Luc said, plus consider using BeginDeferWindowPos() , DeferWindowPos() , EndDeferWindowPos() in your WM_SIZE handler. These APIs allow you to accumulate the movement of multiple windows (controls), and them update them all when the repositioning is finished.
|
|
|
|
|
Hi all,
I want to convert a CString variable to unsigned long long . I know for long we can do it using api atol(long);
but what to use for unsigned long long...
Anybody please help
modified on Tuesday, May 17, 2011 3:44 AM
|
|
|
|
|
|
Yes, but he wants string to long long.
The best things in life are not things.
|
|
|
|
|
I would guess you probably need this[^].
The best things in life are not things.
|
|
|
|
|
|
Hi friends,
I have written simple program of adding and removing columns from using CListCtrl of MFC.
Behavior of the application:
1. When Add button is clicked, its adds 1000 columns to the List control.
2. When Remove Button is clicked it removes the last added 1000 columns from the List Control.
So, when 1000 columns are added to the List Control using InsertColumn() function of MFC, memory usages increased by certain amount(For e.g Say by 500KB), but when we remove the added 1000 columns from the List Control using DeleteColumn() function, the memory is not freed as it was added during the addition of 1000 columns(Only 300KB is freed, resulting in 200KB of Memory Leak).
Create the sample MFC Application and use the below code.
ListControlDlg.cpp
void CListControlDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_LIST, m_List);
}
BEGIN_MESSAGE_MAP(CListControlDlg, CDialog)
.
.
.
ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedAdd)
ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedRemove)
END_MESSAGE_MAP()
BOOL CListControlDlg::OnInitDialog()
{
.
.
.
m_Count = 1;
}
void CListControlDlg::OnBnClickedAdd()
{
int max_limit = m_Count + 1000;
CString columnstr = "Column";
CString Columnno = "";
for (int i = m_Count; i <= max_limit; i++)
{
Columnno.Format("%d", i);
CString columnstrTemp = columnstr + Columnno;
m_List.InsertColumn(i, columnstrTemp, LVCFMT_LEFT, 80);
}
m_Count = max_limit;
}
void CListControlDlg::OnBnClickedRemove()
{
int max_limit = m_Count - 1000;
CString columnstr = "Column";
CString Columnno = "";
for (int i = m_Count; i >= max_limit - 1; i--)
{
Columnno.Format("%d", i);
CString columnstrTemp = columnstr + Columnno;
m_List.DeleteColumn(i);
}
m_Count = max_limit;
}
CListControlDlg.h
class CListControlDlg : public CDialog
{
.
.
.
.
private:
CListCtrl m_List;
int m_Count;
public:
afx_msg void OnBnClickedAdd();
afx_msg void OnBnClickedRemove();
}
ListControl.rc
IDD_LISTCONTROL_DIALOG DIALOGEX 0, 0, 501, 289
STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | WS_MAXIMIZEBOX |
WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
FONT 8, "MS Shell Dlg", 0, 0, 0x1
BEGIN
DEFPUSHBUTTON "OK",IDOK,444,7,50,16
PUSHBUTTON "Cancel",IDCANCEL,389,7,50,16
CTEXT "TODO: Place dialog controls here.",IDC_STATIC,7,174,300,
8
CONTROL "",IDC_LIST,"SysListView32",LVS_REPORT | LVS_ALIGNLEFT |
WS_BORDER | WS_TABSTOP,27,30,454,236,WS_EX_CLIENTEDGE |
WS_EX_LEFTSCROLLBAR
PUSHBUTTON "Add",IDC_BUTTON1,247,7,50,14
PUSHBUTTON "Remove",IDC_BUTTON2,311,7,50,14
END
Abhijit Satpute.
|
|
|
|
|
[The following assumes that you don't have a mismatched new/free somewhere in your code.]
The way this was explained to me, Windows uses a virtual memory concept to allocate/release in chunks of 'pages' 4096 bytes long. Small memory blocks will come from local heap and it is always in physical memory - this is why freeing memory is not "visible" in Task Manager. Large memory blocks will require additional pages to be allocated, and freeing that memory will be visible.
If you want to dig more deeply into this, there are several excellent articles on leak detection here on CodeProject.
You could also experiment by allocating a large block, waiting 10 seconds, then freeing the block while you are watching Task Manager.
|
|
|
|
|
Thanks for your reply.
Can you recommend any tool(other than Task Manager) which can give detailed memory status of the application?
Best Regards,
Abhijit Satpute
|
|
|
|
|
|
Thank you very much Hans.
Regards,
Abhijit
|
|
|
|
|
Abhijit_Satpute wrote: So, when 1000 columns are added to the List Control using InsertColumn() function of MFC, memory usages increased by certain amount(For e.g Say by 500KB), but when we remove the added 1000 columns from the List Control using DeleteColumn() function, the memory is not freed...
How are you verifying this?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
With the help of Task manager. The application memory increases and decreases when we add and delete columns respectively.
Regards,
Abhijit
|
|
|
|
|
Abhijit_Satpute wrote: With the help of Task manager.
Not a good choice. TM does not tell you how much memory your program is using, but the amount of address space that is in use, which differs from the amount of that address space your program is actually using.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
So please suggest me some good tool which can tell me exact memory used by my application.
Regards,
Abhijit
|
|
|
|
|
Abhijit_Satpute wrote: So please suggest me some good tool which can tell me exact memory used by my application.
In all sincerity, why do you think you need to know this?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
My japanese client is using Task Manager to see the memory. So i need to convince him that it is not a memory leak.
Japanese clients are very hard to convince.
Regards,
Abhijit
|
|
|
|
|
Hello,
I wanted to create an application in which I wanted to start my application at specific time, say I wanted to start my application at every 3 PM. If my computer is not on at 3 PM, I must be able to start it on later time as well.
I using VC++/MFC application.
Happy Programming.
|
|
|
|
|
It would be simpler to use the Windows Task Scheduler.
The best things in life are not things.
|
|
|
|
|