|
S_a_n wrote: with the help of FillRect() function
Aha,
Here is the problem. Don't do background erasing like that.
Do background erasing in WM_ERASEBKGND handler. And return TRUE after you finish.
Jesus Loves <marquee direction="up" height="40" scrolldelay="1" step="1" scrollamount="1" style="background:#aabbcc;border-bottom:thin solid 1px #6699cc">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
Could you plz send any sample code...by creating one button in the main window...and changing the background of the main window into transparent....so that the button will visible?
|
|
|
|
|
|
But with this we are not getting any background color intially..bcz whenevr BiginPaint() in WM_PAINT is called the WM_ERASEBKGND is sent to the main window..But i need one initial color at the starting i.e LTGRAY_BRUSH
|
|
|
|
|
|
The same way Iam doing..Could you plz check this code,but intially it is with desktop color...But i need intially the background shud be in LTGRAY_BRUSH and one button on it..
When i click the button some transparent layer has to come over the window and the color has to cover the button also..
#include "stdafx.h"
#include "transparent.h"
#include <commctrl.h>
#define MAX_LOADSTRING 100
// Global Variables:
HINSTANCE hInst; // The current instance
HWND hwndCB,hWndB; // The command bar handle
bool check_flag=false;
void changecolor(HWND hWnd);
// Forward declarations of functions included in this code module:
ATOM MyRegisterClass (HINSTANCE, LPTSTR);
BOOL InitInstance (HINSTANCE, int);
LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK About (HWND, UINT, WPARAM, LPARAM);
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
MSG msg;
HACCEL hAccelTable;
// Perform application initialization:
if (!InitInstance (hInstance, nCmdShow))
{
return FALSE;
}
hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_TRANSPARENT);
// Main message loop:
while (GetMessage(&msg, NULL, 0, 0))
{
if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
return msg.wParam;
}
//
// FUNCTION: MyRegisterClass()
//
// PURPOSE: Registers the window class.
//
// COMMENTS:
//
// It is important to call this function so that the application
// will get 'well formed' small icons associated with it.
//
ATOM MyRegisterClass(HINSTANCE hInstance, LPTSTR szWindowClass)
{
WNDCLASS wc;
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = (WNDPROC) WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_TRANSPARENT));
wc.hCursor = 0;
wc.hbrBackground = (HBRUSH) GetStockObject(LTGRAY_BRUSH);
wc.lpszMenuName = 0;
wc.lpszClassName = szWindowClass;
return RegisterClass(&wc);
}
//
// FUNCTION: InitInstance(HANDLE, int)
//
// PURPOSE: Saves instance handle and creates main window
//
// COMMENTS:
//
// In this function, we save the instance handle in a global variable and
// create and display the main program window.
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd;
TCHAR szTitle[MAX_LOADSTRING]; // The title bar text
TCHAR szWindowClass[MAX_LOADSTRING]; // The window class name
hInst = hInstance; // Store instance handle in our global variable
// Initialize global strings
LoadString(hInstance, IDC_TRANSPARENT, szWindowClass, MAX_LOADSTRING);
MyRegisterClass(hInstance, szWindowClass);
LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
hWnd = CreateWindow(szWindowClass, szTitle, WS_VISIBLE,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
if (!hWnd)
{
return FALSE;
}
hWndB = CreateWindow(L"button",L"",WS_CHILD | WS_VISIBLE | BS_OWNERDRAW,200,300,100,30,hWnd,NULL,hInstance,NULL);
ShowWindow(hWnd, nCmdShow);
UpdateWindow(hWnd);
if (hwndCB)
CommandBar_Show(hwndCB, TRUE);
return TRUE;
}
//
// FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
// PURPOSE: Processes messages for the main window.
//
// WM_COMMAND - process the application menu
// WM_PAINT - Paint the main window
// WM_DESTROY - post a quit message and return
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
int wmId, wmEvent;
PAINTSTRUCT ps;
TCHAR szHello[MAX_LOADSTRING];
LPDRAWITEMSTRUCT lpDIS;
switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case IDM_HELP_ABOUT:
DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
break;
case IDM_FILE_EXIT:
DestroyWindow(hWnd);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
break;
case WM_CREATE:
hwndCB = CommandBar_Create(hInst, hWnd, 1);
CommandBar_InsertMenubar(hwndCB, hInst, IDM_MENU, 0);
CommandBar_AddAdornments(hwndCB, 0, 0);
break;
case WM_DRAWITEM:
lpDIS = (LPDRAWITEMSTRUCT) lParam;
DrawFrameControl(lpDIS->hDC,&lpDIS->rcItem,DFC_BUTTON,DFCS_BUTTONPUSH);
if(lpDIS->itemAction == ODA_DRAWENTIRE)
{
DrawText(lpDIS->hDC,L"Uma",3,&lpDIS->rcItem,DT_CENTER | DT_VCENTER);
}
if(lpDIS->itemAction & ODA_SELECT)
{
DrawText(lpDIS->hDC,L"Selected",3,&lpDIS->rcItem,DT_CENTER | DT_VCENTER);
check_flag=true;
RECT rt;
GetWindowRect(hWnd,&rt);
InvalidateRect(hWnd,&rt,TRUE);
}
break;
case WM_PAINT:
RECT rt;
hdc = BeginPaint(hWnd, &ps);
GetClientRect(hWnd, &rt);
LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);
//DrawText(hdc, szHello, _tcslen(szHello), &rt,
// DT_SINGLELINE | DT_VCENTER | DT_CENTER);
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
CommandBar_Destroy(hwndCB);
PostQuitMessage(0);
break;
case WM_ERASEBKGND:
//HDC hdc;
//hdc = BeginPaint(hWnd,&ps);
if(check_flag)
{
changecolor(hWnd);
}
//MessageBox(hWnd,L"Erasing",L"OK",MB_OK);
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}
// Mesage handler for the About box.
LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
RECT rt, rt1;
int DlgWidth, DlgHeight; // dialog width and height in pixel units
int NewPosX, NewPosY;
switch (message)
{
case WM_INITDIALOG:
// trying to center the About dialog
if (GetWindowRect(hDlg, &rt1)) {
GetClientRect(GetParent(hDlg), &rt);
DlgWidth = rt1.right - rt1.left;
DlgHeight = rt1.bottom - rt1.top ;
NewPosX = (rt.right - rt.left - DlgWidth)/2;
NewPosY = (rt.bottom - rt.top - DlgHeight)/2;
// if the About box is larger than the physical screen
if (NewPosX < 0) NewPosX = 0;
if (NewPosY < 0) NewPosY = 0;
SetWindowPos(hDlg, 0, NewPosX, NewPosY,
0, 0, SWP_NOZORDER | SWP_NOSIZE);
}
return TRUE;
case WM_COMMAND:
if ((LOWORD(wParam) == IDOK) || (LOWORD(wParam) == IDCANCEL))
{
EndDialog(hDlg, LOWORD(wParam));
return TRUE;
}
break;
}
return FALSE;
}
void changecolor(HWND hWnd)
{
RECT wndRect;
UINT uiWidth,uiHeight;
HDC hdc=GetDC(hWnd);
GetWindowRect(hWnd,&wndRect);
uiWidth = wndRect.right - wndRect.left;
uiHeight = wndRect.bottom - wndRect.top;
wndRect.top = 0;
wndRect.left = 0;
wndRect.bottom = wndRect.top + uiHeight;
wndRect.right = wndRect.left + uiWidth;
HBRUSH hBrush = CreateSolidBrush(RGB(120,120,120));//RGB(120 , 230 , 120));
FillRect(hdc, &wndRect, hBrush);
DeleteObject(hBrush);
ReleaseDC(hWnd,hdc);
EnableWindow(hWndB,false);
}
|
|
|
|
|
Sounds like you're painting over the top of your buttons. Handle the WM_CTLCOLORDLG to change the background colour of your dialog.
Example in MFC (important bits):
ON_MESSAGE(WM_CTLCOLORDLG, CtlColourDialog)
afx_msg LRESULT CDialogDlg::CtlColourDialog(WPARAM, LPARAM)
{
return reinterpret_cast<LRESULT>(GetStockObject(BLACK_BRUSH));
}
Steve
-- modified at 1:06 Monday 16th January, 2006
PS: This assumes you're using a dialog.
|
|
|
|
|
like this
CMyClass& CMyClass::CMyClass(CMyClass &myclass)
{
m_private=myclass.m_private;//m_private is a private member variable
}
Is this a bug of vc6 or the standard?
|
|
|
|
|
private variables or functions are not accessible to "other" classes and functions. But you can access them from same class. In copy constructor since you are writing code *in* the same class as private variable it is ok.
hope this helps.
-Saurabh
|
|
|
|
|
It is the standard.
If you think about it, each real-world construction company would need access to the building site in order to complete its contract. If they were not allowed on site, they could not build there, right?
In programming, a constructor is the "first step" for each object, usually used to fill vars with standard values, or - in the case of a copy-constructor - copying values from another class-instance (=object) into the newly created object.
Cheers,
Sebastian
--
Contra vim mortem non est medicamen in hortem.
|
|
|
|
|
Sebastian Schneider wrote: If you think about it, each real-world construction company would need access to the building site in order to complete its contract. If they were not allowed on site, they could not build there, right?
Hmm.... Nice way to explain things. Very interesting...;)
Jesus Loves <marquee direction="up" height="40" scrolldelay="1" step="1" scrollamount="1" style="background:#aabbcc;border-bottom:thin solid 1px #6699cc">
--Owner Drawn
--Nothing special
--Defeat is temporary but surrender is permanent
--Never say quits
--Jesus is Lord
|
|
|
|
|
|
i am making a application which will transfer messages in lan but my transfer messages to other machine but when i try to send messages to own machine then it do not receive message so what is the problem please tell me ASAP.
bankey.khandelwal@solversa.com
Thanks N Regards
Bankey Khandelwal
Mobile : 98504-32990
Office : 020 25521888
Solversa Technologies
15, Yeshwant Ghadge Nagar,
Range Hill Road,
Pune - 03,Maharashtra,India.
|
|
|
|
|
Did you get any error messages?
What's the errno?
Kevin
|
|
|
|
|
Bankey Khandelwal wrote
when i try to send messages to own machine then it do not receive message
whether ur getting same problem when sending tyo other system in LAN.
never say die
|
|
|
|
|
has ur application bound to some port to listen to incoming messages?
-Prakash
|
|
|
|
|
Hey Bankey pls describe your problem in detail
so others on the forum are be able to help u
Enjoy in pune
Ok
bye
Vikas Amin
Embin Technology
Bombay
|
|
|
|
|
when I call FindFirstPrinterChangeNotification(),
in release ,Get Fail,the Error code is 997,it mean the overload I/O is handing.....
but In debug,it's ok!
why?
thanks
|
|
|
|
|
can you post part of the code that is making the API call?
-Prakash
|
|
|
|
|
/* reinitialize the Termination Event so we can proceed */
ResetEvent(g_hTerminateEvent);
hPrinterNotification = FindFirstPrinterChangeNotification(
ThreadParam.hPrinter, /* The printer of interest */
PRINTER_CHANGE_DELETE_JOB, /* We need to know when a job is removed */
0, /* reserved */
&NotificationOptions); /* The details of what notifications that are needed */
/* Check for an error */
if (hPrinterNotification == INVALID_HANDLE_VALUE)
{
LPVOID lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL
);
MessageBox( NULL, (LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION );
LocalFree( lpMsgBuf );
return 0;
}
/*
* Loop on the Notifications, a terminate event, or a refresh event
*/
/* setup for a WaitForMultipleObjects */
Handles[0] = hPrinterNotification;
Handles[1] = g_hTerminateEvent;
Handles[2] = g_hForceRefreshEvent;
/* Initialize for our local data structure */
ZeroMemory(&Queue, sizeof(Queue));
Queue.Printer.hPrinter = ThreadParam.hPrinter;
/* Initialize the display and our local copy of the printer queue data */
CPrinterJob::Refresh(ThreadParam.hWnd, &Queue);
/*
* Loop while we are stilling waiting on Notifications.
*/
while (hPrinterNotification != INVALID_HANDLE_VALUE)
{
/* wait for a printer notification, terminate event, or refresh event */
WaitForMultipleObjects(3, Handles, FALSE, INFINITE);
/* check to see if the thread needs to quit. */
if (WaitForSingleObject(g_hTerminateEvent, 0) == WAIT_OBJECT_0)
{
/* This should be the only way out of the loop */
FindClosePrinterChangeNotification(hPrinterNotification);
hPrinterNotification = INVALID_HANDLE_VALUE;
}
/* or check to see if the notification object for the printer queue is signaled */
else if (WaitForSingleObject(hPrinterNotification, 0) == WAIT_OBJECT_0)
{
/* get the changes and reset the notification */
if (!FindNextPrinterChangeNotification(hPrinterNotification,
&WaitResult, /* for the PRINTER_CHANGE_DELETE_JOB notice */
&NotificationOptions, /* The notifications */
(void **)&pNotification)) /* address of pointer that gets what changed */
{
//ErrorBox(GetLastError(), "FindNextPrinterChangeNotification");
int iiii = 0;
}
/* Did a notification overflow occur? */
if (pNotification && pNotification->Flags & PRINTER_NOTIFY_INFO_DISCARDED)
{
/* An overflow of notifications occured, must refresh to continue */
OldFlags = NotificationOptions.Flags;
NotificationOptions.Flags = PRINTER_NOTIFY_OPTIONS_REFRESH;
FreePrinterNotifyInfo(pNotification);
if (!FindNextPrinterChangeNotification(hPrinterNotification,
&WaitResult,
&NotificationOptions,
(void **)&pNotification))
{
//ErrorBox(GetLastError(), "FindNextPrinterChangeNotification refresh call.");
int jjjj = 0;
}
NotificationOptions.Flags = OldFlags;
/* Start Over with Refreshed Data */
CPrinterJob::Refresh(ThreadParam.hWnd, &Queue);
}
/* process the notification of changes */
if (WaitResult & PRINTER_CHANGE_DELETE_JOB)
{
/* a job was deleted so start over clean */
CPrinterJob::Refresh(ThreadParam.hWnd, &Queue);
}
else
{
/* track and show the changes */
CPrinterJob::RefreshFromNotification(ThreadParam.hWnd, &Queue, pNotification);
}
FreePrinterNotifyInfo(pNotification);
pNotification = NULL;
}
/* Or, maybe the user wants to refresh the view of the print queue */
else if (WaitForSingleObject(g_hForceRefreshEvent, 0) == WAIT_OBJECT_0)
{
CPrinterJob::Refresh(ThreadParam.hWnd, &Queue);
ResetEvent(g_hForceRefreshEvent);
}
Sleep(5);
}
/* Done watching for notifications, cleanup */
ClosePrinter(ThreadParam.hPrinter);
CPrinterQueue::FreeQueueData(&Queue);
/* Thread posts the close message when the application is going away so the
* the application willattempt to close down again and succeed since the
* thread has died.
*/
if (bCloseApp)
PostMessage(ThreadParam.hWnd, WM_CLOSE, 0, 0);
return TRUE;
|
|
|
|
|
How can I programmatically make a button invisible?
I can enable or disable and I can go into properties and
make the button invisible (or visible), but how can I
make it invisible programatically at run-time?
Please, any response any one can give me will be
greatly appreciated.
Sincerely,
Danielle Brina (an overworked graduate student)
|
|
|
|
|
|
I have a dialog-based app that:
- displays an image in a picture control (CStatic)
- has a bunch of labelled text boxes (CStatic & CEdit)
- has a few other bits & pieces (CScrollbar, CComboBox, CCheckBox...)
The app needs to fill as much of the available screen real-estate on the computer running it. I can resize the main dialog window easily enough... but resizing the various controls on it looks like a tedious business.
It's a one-off. Am I just as well off doing the layout calculations by hand, and giving every text box label an ID other than IDC_STATIC to do it... or is there something there that will so dramatically reduce the pain of all this that it is worth learning. On the face of it, CResizableDialog is more effort than it's worth... but I stand to be corrected.
|
|
|
|
|
I believe there's a CP class that does this as well, but you'd have to have a look for yourself, I'm not sure.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
|