|
Hi,
I created a dialog using createdialog() in win32 program .And in that in created a edit box using createwindow.
I have handled WM_CTLCOLOREDIT like this
case WM_CTLCOLOREDIT:
hdc = (HDC)wParam;
SetTextColor(hdc, RGB(0,0,255));
hdc3 = GetDC(c_hwnd);//c_hwnd is handle to button
crBkgnd = GetBkColor(hdc3);
SetBkColor(hdc,crBkgnd);
GetSysColorBrush(COLOR_3DHILIGHT);
break;
here only i can see the change of color in text but background color is not changing to button default color (color is specified in code using crBkgnd)..
whenever text appears background color will be white...
Thanking you
Manjunath S
GESL
Bangalore
|
|
|
|
|
u should return abrush by which u want to draw the background...
case WM_CTLCOLOREDIT:<br />
<br />
<br />
hdc = (HDC)wParam;<br />
SetTextColor(hdc, RGB(0,0,255));<br />
<br />
hdc3 = GetDC(c_hwnd);
<br />
crBkgnd = GetBkColor(hdc3);<br />
SetBkColor(hdc,crBkgnd);<br />
return (LRESULT)GetSysColorBrush(COLOR_3DHILIGHT);
nave
|
|
|
|
|
I have created an edit control like the following ,But when i try to changes to readonly by adding ES_READONLY to edit control .but both text color and background color is changing to default(i.e text to black and background in not changing)when i add ES_READONLY.
c_hwnd = CreateWindowEx(0, "Edit", NULL,WS_CHILD,320, 220,318, 238,
d_hnd, NULL, hInst, NULL);
if(c_hwnd == NULL) {
MessageBox(NULL, "could not create window", "Error", MB_ICONERROR);
return 0;
}
Manjunath S
GESL
Bangalore
|
|
|
|
|
ok..When u add the ES_READONLY style, instead of WM_CTLCOLOREDIT, handle WM_CTLCOLORSTATIC
nave
|
|
|
|
|
See MSDN,
From the MSDN
Read-only or disabled edit controls do not send the WM_CTLCOLOREDIT message; instead, they send the WM_CTLCOLORSTATIC message.
whitesky
|
|
|
|
|
for this work you need to return brush else system use from defalt brush
whitesky
|
|
|
|
|
How I can create a win32 DLL Project in Visual Studio 2003?
Regards
Abhi Lahare
|
|
|
|
|
New Project --> C++ folder --> Win32 Console Application
Then a wizard window will pop up, go to settings and mark the DLL checkbox.
goodluck
|
|
|
|
|
Thanks Alon
Regards
Abhishake
|
|
|
|
|
|
Hai
How can we set images for items on CtreeCtrl
Thanks in advance.
|
|
|
|
|
SetItem( TVITEM* pItem )
Regards
Abhi Lahare
|
|
|
|
|
you need to use
CImageList* SetImageList( CImageList * pImageList, int nImageListType );
before you do insertitem and in that pass the index in the imagelist you need to display .
Regards,
FarPointer
Blog:FARPOINTER
|
|
|
|
|
See SetItem and SetImageList
whitesky
|
|
|
|
|
Thanks for your reply.I got it.
But when I insert items I am getting all the items as root items.How can I insert child items in to the tree
-- modified at 3:02 Monday 10th July, 2006
|
|
|
|
|
Can you show how you to use this function
whitesky
|
|
|
|
|
BOOL CBmDialog::OnInitDialog()
{
CDialog::OnInitDialog();
CImageList list;
list.Create(16, 16, ILC_COLOR8, 0, 4);
CBitmap bm;
bm.LoadBitmap(IDB_BITMAP1);
list.Add(&bm, RGB(0, 0, 0));
m_tree1.SetImageList(&list,TVSIL_NORMAL);
m_tree1.InsertItem("Image1");
m_tree1.InsertItem("Image2");
HTREEITEM h1,h2;
h2=m_tree1.GetNextItem(h1,TVGN_FIRSTVISIBLE);
m_tree1.SetItemImage(h2,0,0);
return TRUE;
}
|
|
|
|
|
I test this code and it work (you need to a resource(bitmap))
<code>
TVINSERTSTRUCT TreeCtrlItem;
CBitmap Bmp;
CImageList *m_ImageList;
HTREEITEM hTreeItem1;
m_ImageList = new CImageList();
m_ImageList->Create(50,50, ILC_COLORDDB,0,0);
Bmp.LoadBitmap(IDB_BITMAP1);
m_ImageList->Add(&Bmp,RGB(155,155,155));
TreeCtrlItem.hParent = TVI_ROOT;
TreeCtrlItem.hInsertAfter = TVI_LAST;
TreeCtrlItem.item.mask = TVIF_TEXT |TVIF_IMAGE|TVIF_SELECTEDIMAGE;
TreeCtrlItem.item.pszText = CA2T("(A)");;
TreeCtrlItem.item.lParam = 0;
TreeCtrlItem.item.iImage=0;
TreeCtrlItem.item.iSelectedImage=0;
hTreeItem1 = m_Tree1.InsertItem(&TreeCtrlItem);
m_Tree1.SetImageList(m_ImageList, LVSIL_NORMAL);
TreeCtrlItem.hParent = hTreeItem1;
TreeCtrlItem.item.pszText = CA2T(" (B)");
TreeCtrlItem.item.lParam = 1;
TreeCtrlItem.item.iImage=1;
TreeCtrlItem.item.iSelectedImage=1;
m_Tree1.InsertItem(&TreeCtrlItem);
m_Tree1.SetImageList(m_ImageList, LVSIL_NORMAL);
whitesky
|
|
|
|
|
Thank you very much
|
|
|
|
|
I have an application that uses threads. The purpose of one thread is to Listen for any communication request from other machines. This has an infinite while loop. There have to be 2 stopping conditions for the same. One is when it receives a Stop boolean variable, it stops the whole application.
The other condition I want to add is that if it sees a global boolean variable is set (which needs to be set by some other thread of the same application) it should end that particular listen thread only (not the whole application). If I use _endthreadex() how will the other thread form which the boolean variable was set know that the listen thread has actually ended?
I was using TerminateThread() to end the Listen thread because it accepts the handle of the thread as an argument so that I was able to end the thread from some other thread but I see it is not cleaning up after Terminating the thread.
|
|
|
|
|
Programmer Anju wrote: The other condition I want to add is that if it sees a global boolean variable is set (which needs to be set by some other thread of the same application) it should end that particular listen thread only (not the whole application). If I use _endthreadex() how will the other thread form which the boolean variable was set know that the listen thread has actually ended?
program listen thread something line this
g_bEndListenThread=FALSE;
while(1)
{
if(g_bEndApplication==TRUE)
// End listen thread
return 0; or _endthreadex();
if(g_bEndListenThread==TRUE)
// End listen thread
return 0; or _endthreadex();
// Do normal functioning
}
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Programmer Anju wrote: The other condition I want to add is that if it sees a global boolean variable is set (which needs to be set by some other thread of the same application) it should end that particular listen thread only (not the whole application). If I use _endthreadex() how will the other thread form which the boolean variable was set know that the listen thread has actually ended?
program listen thread something line this
g_bEndListenThread=FALSE;
while(1)
{
if(g_bEndApplication==TRUE)
// End listen thread
return 0; or _endthreadex();
if(g_bEndListenThread==TRUE)
// End listen thread
return 0; or _endthreadex();
// Dyour Thread functioning
}
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
If a thread or process terminates, the OS-internal thread/process object is set to signaled state - the state you can use to wait for with e.g. WaitForSingleObject(). So if hThread is your thread handle, the following would wait until the thread has actually terminated:
WaitForSingleObject( hThread, INFINITE )
The point is that you might also use the waiting functions to test if an object (in this case the thread) is in signaled state (in this case has terminated) by just using 0 as the timeout value:
if( WaitForSingleObject( hThread, 0 ) == WAIT_TIMEOUT ) {
// not terminated yet
}
--
Daniel Lohmann
http://www.losoft.de
(Hey, this page is worth looking! You can find some free and handy NT tools there )
|
|
|
|
|
Daniel Lohmann wrote: WaitForSingleObject(). So if hThread is your thread handle, the following would wait until the thread has actually terminated:
WaitForSingleObject( hThread, INFINITE )
The point is that you might also use the waiting functions to test if an object (in this case the thread) is in signaled state (in this case has terminated) by just using 0 as the timeout value:
In call of TerminateProcess api, system will close the thread, without releasing any of it memory and related stuff. there might be case the system hang indefinatly at the call of WaitForSingleObject api!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Hai,
I need to disable the pushbutton Retrieve on a dialogbox if no item selected in the list.My problem is iam not able to find the dialog box in the resource editor.
Is there any other way to create a dialogbox otherthan resource editor.
|
|
|
|