Solved

Access main window class from External Function

Posted on 1998-11-13
2
183 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Change owner from userA to server Local Administrators 7 59
haveThree challenge 22 112
abstract class with all non abstract mentods 6 75
Excel file not created as expected 7 46
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

932 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now