|
Where in your code are you calling DrawImage()?
What is the background behind the image and how is it drawn?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I called it at OnEraseBackground()
I would like to have a transparent background (i.e. I set the desktop background to black/white, I hope the image boundary will be "blur" with the work of alpha bending).
I am not sure if what I do is right, however, with using the Graphics::SetCompositingMode() , it seems that the Graphics::DrawImage() method will not directly apply the alpha bending information? ( I use Bitmap::GetPixelFormat() to verify the input image is a PixelFormat32bppARGB type, which means it should include the alpha channel)
|
|
|
|
|
You shouldn't need much more than this...
Bitmap SrcBitmap(L"C:\\Test.png", FALSE);
...
Graphics DstGraphics(hdc);
DstGraphics.SetCompositingMode(CompositingModeSourceOver);
DstGraphics.DrawImage(&SrcBitmap, 0, 0, SrcBitmap.GetWidth(), SrcBitmap.GetHeight());
If something's not working I'd have to see a code sample to possibly help
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mark,
Thanks for your reply ^^
err... what I wrote right now is exactly same as yours... (even the file name )
however, the outcome is just a dark background but not transparent...
Maybe I put at a wrong message call location?
I put the above code under OnEraseBackground()
Vincent
|
|
|
|
|
Hmm...do you have a sample of a png image that isn't working that you can send me to test?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
void CCURLASSIgnmentDlg::OnButton2()
{
CButton *b1;
CString s1,s2;
CEdit *e1=( CEdit *) GetDlgItem(IDC_EDIT1);
e1->GetWindowText(s1);
for(int i=IDC_RADIO1;i<=IDC_RADIO1+nob;i++)
{
b1=(CButton *) GetDlgItem(i);
b1->GetWindowText(s2);
if(s2.Compare(s1)==0)
{
return;
}
}
b1=(CButton *) GetDlgItem(IDC_RADIO1+nob);
b1->SetWindowText(s1);
e1->SetWindowText("");
nob++;
if(nob<18)
{
b1=(CButton *) GetDlgItem(IDC_RADIO1+nob);
b1->ShowWindow(SW_SHOW);
}
else
nob=17;
}
this is my assigement inthis assigement if i press the ok button than display the url.but i want if i dont change ok button but i want entercoding on that ok button.
|
|
|
|
|
What the hell are you talking about ???
yadahav wrote: if i press the ok button than display the url
Which url ??
yadahav wrote: but i want if i dont change ok button but i want entercoding on that ok button.
What is entercoding ?
Sorry, but you really need to explain things more clearly.
What do you want to do exactly ? You want to execute this code when you press the OK button ? If yes, then simply add an event handler for IDOK and paste your code inside.
|
|
|
|
|
Hi All,
I have made a worker thread in which i have defined a critical section using CCriticalSection class. I have started this worker thread inside a for loop.
Now my problem is when i want to stop my thread before completing the for loop(ie i want that all the threads already running should stop as well as no new thread should start). I am not getting the way to do this.
Can anybody help me in this.
Thanks in advance.
|
|
|
|
|
In general the way to do it is to use a flag to tell the thread to continue looping or not: the loop will check this flag and continue its work until it is set.
Then, from your main thread, you can set this flag in order to stop the thread.
But of course, this depends a lot of your current architecture.
|
|
|
|
|
Can you post the sample code snippet.
Upto my understanding, set a flag before start the thread. Based on the flag start or stop your threads in the for loop.
Sreedhar DV
[Real success is having courage to meet failure without being defeated.]
|
|
|
|
|
See here for thread shutdown discussions.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
HI
How to create enter botton in mfc?
|
|
|
|
|
From the toolbar, pull a button onto your dialog.
Place it where you want it, change its caption o read 'Enter' etc.
Add a handler for that button.
What specifically is your problem?
Though I speak with the tongues of men and of angels, and have not money, I am become as a sounding brass, or a tinkling cymbal. George Orwell, "Keep the Aspidistra Flying", Opening words
|
|
|
|
|
yadahav wrote: How to create enter botton in mfc?
You mean befault button?
If so right on a button take properties->Style->tick the Deafult button.
|
|
|
|
|
Do you want to make it with code you can use of CreateWindow("Butotn")... if you want to make a button for enetr you can set id of button to IDOK .
|
|
|
|
|
Hi,
I have a list control on my dialog box.Property is set to Report view & member name is m_Pressure.
CEdit* pEdit = m_Pressure.GetEditControl();
Above function is always returning NULL.
Please help me out
Thanks
|
|
|
|
|
shir_k wrote: CEdit* pEdit = m_Pressure.GetEditControl();
For this function to work, you have set the style LVS_EDITLABELS for list control. Also this function return a pointer only if you started editing the list control.
Either by clicking on list control or by sending the LVM_EDITLABEL( EditLabel()) to the list control.
|
|
|
|
|
In Property of Control list i checked edit labels.
I included NM_Click function as below.
ptrPressInPSI is a pointer to the control list
CListCtrl *ptrPressInPSI;
ptrPressInPSI = &m_Pressure;
void list::OnClickList1(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
CEdit* edit = ptrPressInPSI->GetEditControl();
if (edit)
{
int i;
i=0;
}
*pResult = 0;
}
Any thing wrong in above code.It is still returning NULL
thanks
|
|
|
|
|
shir_k wrote: I included NM_Click function as below.
Use LVN_BEGINLABELEDIT instead.
|
|
|
|
|
Thanks naveen. I got it.
But one question why am not able to use above code in other functions.I want to include copy & paste function for CListCtrl,Below is a code which i got from google
In the below code am facing two problems
1)As i told CEdit* edit = m_Pressure.GetEditControl(); is always NULL
2)when i include CListCtrl& m_list4 = GetListCtrl( ); am getting below errors
D:\JUNE\VC\test1\list.cpp(147) : error C2065: 'GetListCtrl' : undeclared identifier
D:\JUNE\VC\test1\list.cpp(147) : error C2440: 'initializing' : cannot convert from 'int' to 'class CListCtrl &'
BOOL list::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if ( pMsg->message == WM_KEYDOWN )
{
CListCtrl& m_list4 = GetListCtrl( );
CEdit* edit = m_Pressure.GetEditControl();
if (edit)
{
if( GetKeyState( VK_CONTROL ))
{
if( pMsg->wParam == VK_C )
{
edit->Copy();
return TRUE;
}
if( pMsg->wParam == VK_V )
{
edit->Paste();
return TRUE;
}
if( pMsg->wParam == VK_X )
{
edit->Cut();
return TRUE;
}
if( pMsg->wParam == VK_Z )
{
edit->Undo();
return TRUE;
}
}
if( pMsg->wParam == VK_RETURN || pMsg->wParam == VK_ESCAPE ||
pMsg->wParam == VK_CONTROL || pMsg->wParam == VK_INSERT ||
pMsg->wParam == VK_SHIFT )
{
edit->SendMessage(WM_KEYDOWN, pMsg->wParam, pMsg->lParam);
return TRUE;
}
}
}
return CDialog::PreTranslateMessage(pMsg);
}
Please help me out.
Thanks
|
|
|
|
|
GetEditControl() will return only a vaild pointer only if the edit control is visible to the user. in other cases, it will be null.
About the above code, they might have implemented there on edit control in the list control.
shir_k wrote: I want to include copy & paste function for CListCtrl,
Are you trying to paste when the edit control is visible?If so, there is no need of the above code na? You can directly do copy/paste on edit control.
|
|
|
|
|
Hi,
Am able to do copy & paste from the edit box directly but in Control list box it is not possible.
When i checked class definition of
CEdit --> it has clipboard operation
void Clear();
void Copy();
void Cut();
void Paste();
But i didn't find it in CListCtrl.So i thought of using
CEdit* GetEditControl() const;
so once i get handle then i may able to do copy & paste.
Is there any other way to do.
|
|
|
|
|
shir_k wrote: so once i get handle then i may able to do copy & paste.
Suppose you press ctrl+c on the list control. Then what do u expect?
1)The text in first column of selected row is copied?
2) The whole text in list control is copied?
Also what will be the case of ctrl+c?
|
|
|
|
|
i expect it to copy the selected data in the column.Am having only one column.
And i want that data to be pasted in a notepad.
|
|
|
|
|
shir_k wrote: i expect it to copy the selected data in the column
Then no need of the edit control and all.
Directly copy the data from the clipboard and set it as text to the column.
|
|
|
|