|
Buttons are just windows so you can use GetDlgItem() to get a handle to the Window and then use GetClientRect() to get its size/pos.
Neville Franks, Author of ED for Windows www.getsoft.com and coming soon: Surfulater www.surfulater.com
|
|
|
|
|
OK button is IDOK
CWnd* pWndOK = GetDlgItem(IDOK);
ASSERT(pWndOK != NULL);
Then use GetWindowRect()
CRect crOK;
pWndOK->GetWindowRect(&crOK);
The CRect holds the x, y, width and height
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fuity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
I'm new to windows programming and I'm trying to create a basic setup for my program where users go through several screens and input preferences. Seems to me that these are mainly done using MFC dialog boxes, is that true?
thanks for your input
-bacon
|
|
|
|
|
You might want to look at the wizard-type form of Property Sheets...
Steve
|
|
|
|
|
Since you are new to this you probably don’t' want to tackle this, but… The latest approach to "properties" is the list view with tree style behavior. Like the Visual Studio Property view window in the form designer.
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
Dear all,
I am using mfc thread to acquire data from usb port and do signal processing. My signal processing program is written in Borland C++. Since my processing & classification program involves a few of submodules, I would not want to insert it in the thread. Instead I would like to call it from the thread, e.g. processing().
Below is my MFC thread:
UINT Process(LPVOID pParam2)
{
DWORD ExitCode;
int Code=1;
if(status==0)
{
myWinThread = AfxBeginThread(SendOpThread, &Code,
THREAD_PRIORITY_HIGHEST,0,CREATE_SUSPENDED);
myWinThread->m_bAutoDelete=FALSE;
myWinThread->ResumeThread();
status=1;
}
ExitCode=STILL_ACTIVE;
while(ExitCode==STILL_ACTIVE)
{
::GetExitCodeThread(myWinThread->m_hThread,&ExitCode);
}
for (int i=0; i<1024;i++)
{
j=i/4;
k=i%4;
channel[k][j]=r_Buffer[i];
}
delete myWinThread;
myWinThread = AfxBeginThread(SendOpThread, &Code,
THREAD_PRIORITY_HIGHEST,0,CREATE_SUSPENDED);
myWinThread->m_bAutoDelete=FALSE;
myWinThread->ResumeThread();
//signal processing occurs here
return(1);
}
Below is an example structure of my processing program:
#include <stdio.h>
#include <conio.h>
int i;
void Read();
void Save();
int main()
{
}
void Read()
{
}
void Save()
{
}
Can I use Callback routine? I came across some examples that uses this. What is it actually doing? Will my thread routine (UINT Thread) wait for the processing program to finish processing before execute the next line if I use call back function for the processing program? Any other better way of doin this?
Any examples that call other module from a thread?
Thanks a lot
Einly
|
|
|
|
|
You are asking multiple questions in just a couple of lines. Essentially, what do you want to know? Multithreading is compiler indepennt.
Kuphryn
|
|
|
|
|
I wrote a function a while back to clean out a directory and all of its contents and tried re-writing the same one tonight but can't seem to get it right. Any chance someone can point out my mistake?
short ClearEntireDirectory(char *szDirectory)
{
HANDLE hFile;
WIN32_FIND_DATA wfd;
if ( SetCurrentDirectory(szDirectory) == 0 )
return 1;
hFile = FindFirstFile("*.*", &wfd);
while ( FindNextFile(hFile, &wfd) != 0 )
{
if ( wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY &&
strcmp(wfd.cFileName, "..") != 0 &&
strcmp(wfd.cFileName, ".") != 0
)
{
if ( ClearEntireDirectory(wfd.cFileName) == 1 )
return 1;
}
DeleteFile(wfd.cFileName);
}
if ( SetCurrentDirectory("..") == 0 )
return 1;
if ( RemoveDirectory(szDirectory) == 0 )
return 1;
FindClose(hFile);
return 0;
}
I keep getting error 32 (ERROR_SHARING_VIOLATION) when I try to ultimatelly remove the directory.
|
|
|
|
|
I'm such an idiot!!! It would help if FindClose cam before RemoveDirectory!!!!!
|
|
|
|
|
The calls to SetCurrentDirectory() are unnecessary. If the usage of this function is low, it probably makes no difference, but if it is an oft-used function, changing directories so many times is not efficient.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Hi,
I m developing an application that displays Bitmaps on Window....
he problem is that the bitmap dispayed using 256 color scheme, but i want show my bitmaps with high-resolution.
Thanks in advance.
|
|
|
|
|
|
Hi,
I m developing application that displays Window with Lines, Bitmaps, but I haven't used any Document-View Architecture.
I have developed Dialog-based application and then instead of displaying Dialog , I m displaying Window usig CFrameWnd class on InitInstance of Application.
When any other Window overlapes over my Application Window,it erases the Graphics.....
I tried to use OnPaint(ON_WM_PAINT) event to solve the problem , but the event has been called continuously...
I grately Thankful to have the solution as soon as possible.
Or is there any other ways to solve the problem.
Thanks in advance.
|
|
|
|
|
I would immediately scrap the project and create a new one using MFC instead of trying to violate it. CFrameWnd is the frame of a view. You are expected to have a view to draw the application data to. Using a CFrameWnd in a dialog-based application is very much trying to combine the worst from two worlds, just don't do it. If you have started out with a dialog-based application, and have now decided to go the full route with a proper SDI- or MDI-based application, the advice is the same: scrap the old application and create a new project with the wizard if you don't know how it should be built by hand.
Second, that you have a window not redrawing after being covered and then uncovered implies that you draw outside of OnDraw in the view. Ooops! You have no view - well well, outside the application main window WM_PAINT -handler then.
Calling OnPaint yourself is completely inappropriate - you are supposed to invalidate the view, which sooner or later triggers a WM_PAINT , which makes MFC call your OnPaint , which probably is not drawing anyway - implied from your error description. If you want to trigger an immediate redraw, call RedrawWindow .
So, one step back, get the hang of the structure of SDI/MDI-apps, not least as regards visual updating. Otherwise you'll get into lots of frustrating situations in the future.
|
|
|
|
|
hi:everyone:
tell you i have some model ,but some of them is written using ODBC,but others is written using ADO,now i want to integrate them into a big project,i want to know whether it is ok?
thank you
|
|
|
|
|
>> can ADO and ODBC be mixed
I don't know... did you try it? Did it work?
"No matter where you go, there your are." - Buckaroo Banzai
-pete
|
|
|
|
|
You will need multiple connections to the database, one for ADO and one for ODBC. If this is acceptable I can't see why it would not work.
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fuity and sweet. I'm jelly, what am I? Muse on it further, I shall return! - David Williams (Little Britain)
|
|
|
|
|
Hi there,
I have a group of three checkboxes. When I click on CheckBox2, a dialog box appears asking for user input. What it's suppose to do is when a user cancels a selection it should default to the first checkbox by making a call to CheckRadioButton. It does default but once the user clicks away from the application, the dialog box reappears as if the function to open up the dialog box is called once again. I isolated the problem and found that its the CheckRadioButton() that causes it. I don't know how or why but its the main source of the problem. How can I correct this?
Please see my code below. Thanks.
void CCheckBox::OnCheckBox2
{
CMyDialog dlg;
int nRet = -1;
nRet = dlg.DoModal();
// Handle the return value from DoModal
switch ( nRet )
{
case -1:
AfxMessageBox("Dialog box could not be created!");
break;
case IDOK:
{
..code...
break;
}
case IDABORT:
{
OnCheckBox1();
break;
}
case IDCANCEL:
{
OnCheckBox1();
break;
}
default:
break;
};
}
void CCheckBox::OnCheckBox1()
{
CheckRadioButton(IDC_RADIO1, IDC_RADIO3, IDC_RADIO1);
}
|
|
|
|
|
Sounds like recursive calls.
Kuphryn
|
|
|
|
|
But how is it recursive on the dialog box when all I am doing is checking the first check box? I can see it being recursive in that everytime I call CheckRadioButton() to check the first button it calls OnCheckBox1() again. I still don't understand why it would recursively call the dialog box as well. Help please. Thanks!
|
|
|
|
|
Are you calling UpdateData in the right place\correctly?
Sounds like the associated member variable is not being kept up-to date as you are expecting.
You may already know this, but its a possiblilty all the same!!
|
|
|
|
|
I inserted UpdateData() at the beginning of both OnCheckBox1() and OnCheckBox2() and UpdateData(FALSE) at the end of each but it still doesn't work. It just doesn't like CheckRadioButton(button1, button2, button3) in OnCheckBox1(). That's what causes it to be recursive. Any ideas? Thanks.
|
|
|
|
|
Hi,
I want to minimize all windows before I start my dialog. Is there any command I can use or I should run the ShowDesktop.scf file? I know the file contains Windows Explorer Command as the following:
[Shell]
Command=2
IconFile=explorer.exe,3
[Taskbar]
Command=ToggleDesktop
Thank you in advance,
5iveboy
|
|
|
|
|
|
Dear all,
I want to execute a separate program from my dialog using a button. I have used WinExec, ShellExecute and CreateProcess and get the same problem. The button works fine as long as I build and run my program from Visual C++. But when I run the program independently by double-clicking its exec file from its folder and try the button, it does not work and the other application does not start. This happens on any operating system I tried. Here is the code:
HINSTANCE HINSCursorsd = ShellExecute (NULL,"open","../TestExeNew.exe",NULL,NULL,SW_SHOWNORMAL);
Your help is most greatly appreciated.
Thanks,
|
|
|
|