|
I tried using SetParent on all the buttons as below but now I don't see any buttons anywhere ! Did I miss something ? Do I need to set some extra things ?
BOOL CDesignEditDlg::OnInitDialog() <br />
{<br />
CDialog::OnInitDialog();<br />
<br />
<br />
CWnd* pImage ;<br />
WINDOWPLACEMENT wpImage ;<br />
CRect rect;<br />
CPoint imgPos ;<br />
<br />
pImage = GetDlgItem(IDC_PAGEIMAGE) ;<br />
pImage->GetWindowPlacement(&wpImage);<br />
imgPos.x = wpImage.rcNormalPosition.left ;<br />
imgPos.y = wpImage.rcNormalPosition.top ;<br />
<br />
<br />
int b ;<br />
for(b = 0 ; cButPos[b].id > 0 ; b++) {<br />
pImage = GetDlgItem(cButPos[b].id);<br />
pImage->GetWindowRect(rect);<br />
pImage->MoveWindow(imgPos.x + cButPos[b].x, imgPos.y + cButPos[b].y, rect.Width(), rect.Height(), TRUE);<br />
<br />
pImage->SetParent(this) ;<br />
}<br />
<br />
<br />
cBmp[0].LoadBitmap(IDB_IMAGE0);
cBmp[1].LoadBitmap(IDB_IMAGE1);<br />
<br />
<br />
return TRUE;
}
|
|
|
|
|
Ah ha !
Got it sussed. I should have used SetParent on the picture control and all its overlaping buttons to make them all children of the CDialog. I had to set the WS_CLIPCHILDREN/WS_CLIPSIBLINGS for the dialog/picture control to make it work. Without setting these properties the buttons don't display.
My code now looks like this with no "button redraw's" in the buttons select function.
BOOL CDesignEditDlg::OnInitDialog()
{
CDialog::OnInitDialog();
CWnd* pImage ;
WINDOWPLACEMENT wpImage ;
CRect rect;
CPoint imgPos ;
ModifyStyle(0, WS_CLIPCHILDREN) ;
pImage = GetDlgItem(IDC_PAGEIMAGE) ;
pImage->GetWindowPlacement(&wpImage);
imgPos.x = wpImage.rcNormalPosition.left ;
imgPos.y = wpImage.rcNormalPosition.top ;
pImage->ModifyStyle(0, WS_CLIPSIBLINGS);
pImage->SetParent(this) ;
CWnd* pButton ;
int b ;
for(b = 0 ; cButPos[b].id > 0 ; b++) {
pButton = GetDlgItem(cButPos[b].id);
pButton->GetWindowRect(rect);
pButton->MoveWindow(imgPos.x + cButPos[b].x - (rect.Width()/2), imgPos.y + cButPos[b].y, rect.Width(), rect.Height(), TRUE);
pButton->SetParent(this) ;
}
cBmp[0].LoadBitmap(IDB_IMAGE0);
cBmp[1].LoadBitmap(IDB_IMAGE1);
return TRUE;
}
void CDesignEditDlg::ButtonPressed(int btn)
{
m_ctrlPageImage.SetBitmap(cBmp[1]);
CColourFaderDlg dlg;
dlg.iFaderLineNo = btn ;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
}
else if (nResponse == IDCANCEL)
{
}
m_ctrlPageImage.SetBitmap(cBmp[0]);
}
void CDesignEditDlg::OnButtonSel1()
{
TRACE("Button 1\n") ;
ButtonPressed(1) ;
}
|
|
|
|
|
Neil Urquhart wrote: // Make each CButton a child to CDesignEditDlg
pButton->SetParent(this) ;
No, as I said make the buttons child controls of the image. In your code this would probably be pButton->SetParent(pImage) and you do not necessarily need WS_CLIPCHILDREN/WS_CLIPSIBLINGS in this case.
Here a visualisation of how the client-parent hierachy should look like:
dialog
|_____image
| |_____button1 over image
| |_____button2 over image
| |_____button3 over image, etc
|_____ other controls
Overlapping controls must not be siblings, hope this makes it more clear.
|
|
|
|
|
I am afraid this doose not seem to work in that the buttons are displayed but when I click on the overlapped buttons nothing happens. I think the picture control is taking the input and not passing it onto the buttons.
My version that makes the picture control and buttons children of the dialog does work. Requires the WS_CLIPCHILDREN & WS_CLIPSIBLINGS properties also.
This is the code that does not work :
BOOL CDesignEditDlg::OnInitDialog()
{
CDialog::OnInitDialog();
CWnd* pImage ;
WINDOWPLACEMENT wpImage ;
CRect rect;
CPoint imgPos ;
pImage = GetDlgItem(IDC_PAGEIMAGE) ;
pImage->GetWindowPlacement(&wpImage);
imgPos.x = wpImage.rcNormalPosition.left ;
imgPos.y = wpImage.rcNormalPosition.top ;
pImage->SetParent(this) ;
CWnd* pButton ;
int b ;
for(b = 0 ; cButPos[b].id > 0 ; b++) {
pButton = GetDlgItem(cButPos[b].id);
pButton->GetWindowRect(rect);
pButton->MoveWindow(imgPos.x + cButPos[b].x - (rect.Width()/2), imgPos.y + cButPos[b].y, rect.Width(), rect.Height(), TRUE);
pButton->SetParent(pImage) ;
}
This version of the code does work though!!
BOOL CDesignEditDlg::OnInitDialog()
{
CDialog::OnInitDialog();
CWnd* pImage ;
WINDOWPLACEMENT wpImage ;
CRect rect;
CPoint imgPos ;
ModifyStyle(0, WS_CLIPCHILDREN) ;
pImage = GetDlgItem(IDC_PAGEIMAGE) ;
pImage->GetWindowPlacement(&wpImage);
imgPos.x = wpImage.rcNormalPosition.left ;
imgPos.y = wpImage.rcNormalPosition.top ;
pImage->ModifyStyle(0, WS_CLIPSIBLINGS);
pImage->SetParent(this) ;
CWnd* pButton ;
int b ;
for(b = 0 ; cButPos[b].id > 0 ; b++) {
pButton = GetDlgItem(cButPos[b].id);
pButton->GetWindowRect(rect);
pButton->MoveWindow(imgPos.x + cButPos[b].x - (rect.Width()/2), imgPos.y + cButPos[b].y, rect.Width(), rect.Height(), TRUE);
pButton->SetParent(this) ;
}
|
|
|
|
|
Neil, are you sure the second example works reliable? I wonder because, it does nothing regarding client-parent hierachy, SetParent(this ) in a dialog just sets the existing parent again.
If you want the dialog to receive notifications from the buttons use SetOwner(this) additional to SetParent(pImage) . Alternatively, let the image control handle the button clicks.
Cheers
/M
|
|
|
|
|
Second example is definatley the one that works !!
I tried again making buttons SetParent(pImage) and SetOwner(this) and still the buttons don't respond to clicks.
|
|
|
|
|
Please try the following: Show your dialog, take another window (e.g. Windows Explorer) and move it over your dialog a couple of times. Does the redrawing work as it should, image and buttons are visible?
|
|
|
|
|
|
Great! If you see some painting problems in the future, feel free to post again.
|
|
|
|
|
Hi All,
I want to know which OS am using from C code.Is it is possible?.
Thanks
Mohan t
|
|
|
|
|
Have you looked at GetVersion() ? (it's platform dependent)
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
Does Linux provide that?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Actually i have created one dll USING Windows OS AND ONE MORE DLL USING Unix,so i want to know which dll created from which OS(from C programming).
Gimme an IDEA .
Thanks,
Mohan.T
Mohan tC
|
|
|
|
|
Well, since you've already created the platform-independant code then both your dynamic libraries may provide a function, say tellMeTheOS() .
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
If you've used the right naming conventions, the Windows one will have a .dll extension, the Unix one a .so (for shared object) extension
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
You can't. In your build system you need to handle this, for example on Windows you will build a DLL/LIB and on Linux a SO/A. Once you know on which target you are, you can find out on runtime which Windows version or Linux distibution the code runs on. So you will need specific C/C++ code for different platforms.
|
|
|
|
|
I'm capturing image data from a webcam using a simple class found here[^].
CVFWCapture cap;
PBITMAPINFO pBitmap = NULL;
ULONG BitmapSize;
if(!cap.Initialize())
{
MessageBox(NULL, _T("Failed to initialise capture device. Terminating."), _T("Error!"), MB_OK);
return 0;
}
if(!cap.CaptureDIB(&pBitmap, 0, &BitmapSize))
{
MessageBox(NULL, _T("Failed to capture image from device. Terminating."), _T("Error!"), MB_OK);
return 0;
}
else
{
}
With the above code, I get a PBITMAPINFO structure which contains all the header data of the file, but there's no way for me to access the pixel data from this struct (obviously the struct is the header of a bmp file only). Is there a function I can use to get a pointer to the pixel data from this struct? From the way the class was advertised in the article, I was under the impression this class is used to capture image data - surely there isn't much use in only being able to access header info... Am I wrong or am I just missing something?
|
|
|
|
|
Sauce! wrote: Is there a function I can use to get a pointer to the pixel data from this struct?
AFAIK no.
[added]
From a quick look at article source code, it looks like the pixel data section (after the CaptureDIB call) is in memory just after the BITMAPINFO struct (like bitmap files).
[/added]
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
modified on Tuesday, September 15, 2009 8:39 AM
|
|
|
|
|
In that case, does anybody know of any existing libraries that will allow me to simply capture pixel data from a video device?
|
|
|
|
|
Hi VC++ programmers,
how to programmatically and silent create MSWord document using .dot file as a template and data from dialog based app ? Env: VS6, WordXP/Word2003, WinXP.
Thanks in advance.
|
|
|
|
|
Create an instance of Word's Application object, then use the Add method of the Application's Documents property to create the document - you can specify the template in that method call.
Don't know what you mean by "data from dialog based app"
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks for reply.
I mean get text from various fields and insert into specific places in document.
|
|
|
|
|
Well - getting text from dialog fields - you can find that out from any number of places - this link[^] should help.
As for inserting into the document - well, you need to navigate through the document using the Word object model. The Document object has a Content property, which is a Range object representing the main flow of text in the document. A Range object has various properties (like Paragraphs or Characters properties) that allow you to manipulate the text in the document. Prototype in Visual BASIC - it's a lot quicker and easier.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks,
now I know the way to investigate the issue
|
|
|
|
|
Hi friends,
Below line contain my code.I m writting data into the text file.i have acess database and i write this databse into text file format. my access databse table contain 99 records and i m using CDaoRecordset MoveNext() to get next record data.Problem is that i get record till 18 its ok but after that i get 20 position record and afterthat i get 19 position record.then i get 26 to 30 position record and then i get 21 to 25 record data.But data in the database table is sequentially.So why this problem will occour i wont understand.
Plz help me..
m_pRecordSet = new CDaoRecordset(m_pDatabase);
CString strTablename = _T("pdpstate");
m_pRecordSet->Open(dbOpenTable,strTablename);
int nRecordCnt = m_pRecordSet->GetRecordCount();
int nFieldCnt = m_pRecordSet->GetFieldCount();
CDaoFieldInfo cTempdaoFieldInfo;
CString csSetID,csFieldStr;
CStdioFile cTestFile;
cTestFile.Open(_T("d:\\Jitu45.txt"),CStdioFile::modeCreate | CStdioFile::modeWrite);
for(int nfCnt = 0; nfCnt < nFieldCnt; nfCnt++)
{
m_pRecordSet->GetFieldInfo(nfCnt,cTempdaoFieldInfo);
cTestFile.WriteString(cTempdaoFieldInfo.m_strName);
cTestFile.WriteString(_T(","));
}
cTestFile.WriteString(_T("\n"));
while(!m_pRecordSet->IsEOF())
{
COleVariant variantTemp;
//..// Move through fields in current record..
int nFields = m_pRecordSet->GetFieldCount();
for ( int i=0; i < nFields; i++ )
{
variantTemp.Clear();
variantTemp = m_pRecordSet->GetFieldValue(i);
csSetID.Format(_T("%d"),variantTemp.intVal);
cTestFile.WriteString(csSetID);
cTestFile.WriteString(_T(","));
}
cTestFile.WriteString(_T("\n"));
m_pRecordSet->MoveNext();
}
cTestFile.Close();
|
|
|
|