Solved

Access main window class from External Function

Posted on 1998-11-13
2
193 Views
Last Modified: 2013-11-20
hi folks,

   Here is the question:

UINT ComputeThreadProc (LPVOID pParam) {

   // Codes of retrieving window Controls from Main Window

   return 0;
}

   Could anyone send me a sample codes of retrieving window controls (e.g. Edit, Listbox...etc) from the main window or dialog.

Many thanks.

stephen
0
Comment
Question by:stephenkong
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 6

Accepted Solution

by:
thresher_shark earned 50 total points
ID: 1324671
What I would do is:

1) As the pParam, send a pointer to a CWnd, or if necessary, a structure that contains a pointer to a CWnd.
2) This CWnd is a pointer to the main window or dialog.  In the thread function, you could then use the pointer to access all of the window's edit controls, list boxes, etc... using, for example, GetDlgItem (...);

Here is an example (like you requested):

// MainWindow contains a pointer to a CWnd
UINT ComputeThreadProc (LPVOID MainWindow)
{ CWnd *mainwnd = (CWnd *) MainWindow;

  // then you can do whatever you want with it, for example:
  mainwnd->GetDlgItem (IDC_EDIT_CONTROL1)->ShowWindow (SW_SHOW);

  return 0;
}

If you have any further questions, please feel free to ask.  Thanks!
0
 
LVL 6

Expert Comment

by:thresher_shark
ID: 1324672
Make sure you accept or reject answers at the questions you have asked so far.  It is important to not only ask questions, but also to follow through on them!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
sumDigits challenge 9 172
sum13 challenge 24 135
zeroMAx challenge 20 127
Sed question 2 125
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question