tags:

views:

98

answers:

2

Hi!

I have rewrited a simple MFC application in MS Visual Studio 2008, and now it is working how i wanted. My only problem is, that i have to press a button, and i don't want. It should work automatically. I also noticed that the function are somehow called automatically.

These function are called each after:

  CGetFileListDlg::CGetFileListDlg(CWnd* pParent /*=NULL*/)  
  void CGetFileListDlg::DoDataExchange(CDataExchange* pDX)  
  BEGIN_MESSAGE_MAP(CGetFileListDlg, CDialog)   
  BOOL CGetFileListDlg::OnInitDialog()   
  void CGetFileListDlg::OnPaint()   

My function, which i want called automatically is : void GetFileListDlg::OnBnClickedButtonGetFileList(). If i call my function from OnPaint (which is last called), my application is working, but i can't see nothing, untill the functions have ended. OnPaint is called more than 20 times (i don't know why). So what should i do(if it is possible somehow), that after OnPaint my void CGetFileListDlg::OnBnClickedButtonGetFileList() function should automaticall be called?

Thanks in advance!

kampi

EDIT:

What my CGetFileListDlg::OnBnClickedButtonGetFileList() function does is this: It queries for two given path for the filelist and then compares them. OnPaint is called more than 20 time, and that's the reason why this isn't good for me, because when i call this function there, it will be called more than 20 times, and why it is being called the OnPaint function, doesn't ends, and that's why i can't see the data. If i call my function in OnInintDialog, then it works, almost fine, but then it ends before, i can see the window.

A: 

Depending on what your function(CGetFileListDlg::OnBnClickedButtonGetFileList()) does(which you should add to your question), you can just overload one of the other windows messages, like WM_INITDIALOG(which should be 'CGetFileListDlg::OnInitDialog' in your code) and add any initialization there

Necrolis
Hi! I edited my question. Hope now you understand what i want to do. If i thought correctly, than you suggested i should call my function, in the OnInitDialog function, but this isn't neither what i wanted.
kampi
A: 

Hi!

PostMessage(WM_COMMAND, MAKEWPARAM(IDC_BUTTON_GET_FILE_LIST, BN_CLICKED), 0); This is the command what i needed. This command will manipulate my button like it has been clicked.

Thanks for your help anyway.

kampi

kampi