|
Stephen Hewitt wrote: If the programmer simply commented it out...
But nested comments are not allowed. That's where #if 0 is of use.
"The words of God are not like the oak leaf which dies and falls to the earth, but like the pine tree which stays green forever." - Native American Proverb
|
|
|
|
|
|
I agree that large blocks of #if 0 'd code are annoying but VS2005 improves things a lot by greying it out. It even greys out (for example) #ifdef _DEBUG blocks when _DEBUG is not defined.
The opinions expressed in this communication do not necessarily represent those of the author (especially if you find them impolite, discourteous or inflammatory).
|
|
|
|
|
I believe that in Visual C++ 6.0 there is a key combination that will take you to / from
#if
and
#endif
but Microsoft in their 'wisdom' removed this very handy functionality from VC++.NET 2001. Yes, thanks Microsoft...
Personally, when I need to comment out large chunks of code, I use
#if defined dfkagtljarogh
#end if // defined dfkagtljarogh
where dfkagtljarogh is the result of some random keystrokes. Copy and paste to make sure that two instances match, and then it is not too bad to use Find to jump from beginning to end or vice versa.
And as for being unable to nest /* ... */ comments in C++, this is an abomination that should never have been put into the language. Is there any reason whatsoever why C++ (or C even) HAVE TO REFUSE to allow such useful nested comments?
Thanks again, Microsoft. Some C++ compilers do allow this.
Shraddhan
|
|
|
|
|
Shraddhan wrote: And as for being unable to nest /* ... */ comments in C++, this is an abomination that should never have been put into the language. Is there any reason whatsoever why C++ (or C even) HAVE TO REFUSE to allow such useful nested comments?
yes i agree with you and that is one thing that I hate in VC++ compiler.
-Prakash
|
|
|
|
|
|
|
I have small webserver which is able to handle html files only by default. But now I need to enable it to process ASP page. Is it possible or is any component available ?
|
|
|
|
|
which webserver are you talking about ?
it would depend if that webserver has support for ASP or has plugins to process ASP.
IIS has ASP engine that can be installed to process ASP.
-Prakash
|
|
|
|
|
I have source code of a simple web server. So I have my own web server. Now I want my web server to process ASP coding. I should not install IIS/PWS.
|
|
|
|
|
Like I said your new webserver should provide a plugin to process the ASP script.
like you said it is a simple webserver, it has probably just implemented the HTTP protocol, i.e. deliver the content on clients request.
-Prakash
|
|
|
|
|
I am trying to develop custom visualizers for native code in Visual Studio 2005. As I understand they were available for native code in beta's but were removed from release version.
So I am thinking to add a custom menu in code window contextmenu, hook with debugger, get the data for selected variable, identify type using RTTI or provide a dialog where user can enter types and then render it. Is this approach fesiable?
Another problem I have is there is not enough documentation for extending VS IDE using native code. So right now I am not even able to add a context menu on right click. I can see the menu I am trying to add sometimes but add-in always crashes. I tried articles on CP and none of them added a context menu in native code. Any pointers or advice for articles or samples will be much appreciated.
thanks,
-Saurabh
|
|
|
|
|
I have tried a product called 'Visual Watch' which provides such functionalities. But it doesn't support VS 2005 yet.
|
|
|
|
|
does it support adding user defined classes or structures.
thanks,
Saurabh
|
|
|
|
|
I have 10 button controls, when iam changing the back ground color of the main window, all the button controls in the main window are not visible, My question is How ro make the transparent back ground so that all the button controls should be visible..
Please send me if any ....its very urgent..
|
|
|
|
|
S_a_n wrote: when iam changing the back ground color of the main window
How are you changing the background color of the main window.
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
|
|
|
|
|
with the help of FillRect() function..by getting the DC and rectangle of the main window...
|
|
|
|
|
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?
|
|
|
|
|