Re: Why can't I see static variables in debug window



Paul!

Can this have something to do with the fact that I am using EVC++ in
emulator mode?

Just wondering!
--
Best regards
Robert


"Robby" wrote:

Hey Paul, I really want to beleive you man! :)

But here it goes!

Okay Paul, refering to my code snippet below, then tell me....If I put a
break point on the following line:

case WM_CREATE:

Then why am I still not seeing the value of cxChar? I don't see it in
Auto,Local or under cursor!

or also if I put a break point on the following line:

case WM_SIZE:

Then why am I still not seeing the value of cxClient?

Hers the code:
==============================================
LRESULT CALLBACK MainWndProc ( HWND hWnd, UINT wMsg,
WPARAM wParam, LPARAM lParam)
{
static int cxChar, cxCaps, cyChar, cxClient,cyClient, iMaxWidth;
HDC hdc;
int i, y, iVertPos, iPaintBeg, iPaintEnd; //x,orzPos,
PAINTSTRUCT ps;
SCROLLINFO si;
TEXTMETRIC tm;

switch(wMsg)
{
case WM_CREATE: //*BREAK POINT HERE*
hdc = GetDC (hWnd);
GetTextMetrics(hdc,&tm);
cxChar = tm.tmAveCharWidth; //Why is cxChar's value not
viewable?
cxCaps = (tm.tmPitchAndFamily & 1 ? 3 : 2) * cxChar /2;
cyChar = tm.tmHeight + tm.tmExternalLeading;

ReleaseDC (hWnd,hdc);

iMaxWidth = (40 * cxChar) + (22 * cxCaps);
return 0;

case WM_SIZE:
cxClient = LOWORD (lParam);
cyClient = HIWORD (lParam);

// Set vertical scroll
si.cbSize = sizeof(si);
si.fMask = SIF_RANGE | SIF_PAGE;
si.nMin = 0;
si.nMax = NUMLINES-1;
si.nPage = cyClient / cyChar;
SetScrollInfo (hWnd,SB_VERT,&si,TRUE);

return 0;
=====================================================


I think we are both saying ythe same thing, its just that its not working
for me!!!!!

Story of my life! ;-)

Get back buddy!

--
Kind regards
Robert


"Paul G. Tobey [eMVP]" wrote:

No, there are sub-contexts (for lack of a term that I can remember from the
C++ spec), and, if you aren't using that variable in those contexts, you
won't see it in the Auto page. For example, here's my test WndProc:

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM
lParam)
{
HDC hdc;
int wmId, wmEvent;
PAINTSTRUCT ps;
TCHAR szHello[MAX_LOADSTRING];
static
int sEvent = 6;

switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);

sEvent += wmEvent;

// 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_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;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return 0;
}

As you can see, the static is visible to the whole routine. If you set a
breakpoint in the handler for WM_COMMAND, the variable will appear in the
Auto pane of the variable window, because you're about to use it (to add
wmEvent to it). *However*, if you set a breakpoint in WM_DESTROY, you
*won't* see the static in the Auto pane, presumably because you aren't using
it in that case. It's in scope, but the Auto view is obviously trying to
help you concentrate on those items you're actually using.

As I said, you can use the Locals pane to see everything...

Paul T.

"Robby" <Robby@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:FCADAD78-4451-4CAD-B68C-994AA7412FB1@xxxxxxxxxxxxxxxx
Hi Paul, I hope your are doing fine!

Thankyou for answering my post.

Paul:
From what you wrote in the previous post:

"You'll find that, if you're *using* the static in the context where you
hit
a breakpoint, the value *is* shown."

Well I must say, unfortunately for me, thats not what happens, its not
that
I don't believe you, its just that their must be some setting thats not
set
right in my EVC++!

My variable is declared locally in WinProc as a static int, lets call it
x.
Okay, therefore, in any code which resides in my handlers where my
variable
is existing, I should be able to put a break point on the same line where
my
variable exists and when my program hits this break point, I should be
able
to view x's value.... right? But I don't ! I tried viewing it with my
cursor
over it or by the variables local debug window and no luck.

Having said this, I must point out something on another quote:

"If you change the variables window to show Locals, you'll see it, if it
has
local scope."

According to me, x has a local scope, and as I look in my "Locals" tab of
my
Variables debug window, the value of the variable x does not show. Is
there
some special setting to set in EVC++ to to show Locals?

Anyhow, ... I spent all day on this, and I can't wait to resolve this,
Please get back if you have any other sugestions.

Again, thanks for your time!

--
Kind regards
Rbert


"Paul G. Tobey [eMVP]" wrote:

No, I'd say that microsoft.public.windowsce.embedded.vc is the right
place,
since this is an eVC question, but we'll try answering here.

So, you're expecting to see the variable in the Auto version of the
variables window no matter what the context is? You'll find that, if
you're
*using* the static in the context where you hit a breakpoint, the value
*is*
shown. If you're expecting it to show up when your code isn't using it,
yes, you're out of luck. If you change the variables window to show
Locals,
you'll see if, if it has local scope. If it's a global, you can always
find
it in the source window and float the mouse cursor over it to see the
value.

Paul T.


"Robby" <Robby@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:ED17B518-8547-406C-876F-52EC92FCDB69@xxxxxxxxxxxxxxxx
Hi,

I would like to excuse myself for double posting this question, however
I
believe the nature of this question would be better posted in 'Embeded
general questions' for it is more of a general question than a
programming
one.

I am a <newbie> to eVC++, and I was wondering why is it that when I am
in
debuging mode with the debug and variables watch windows open ayt the
bottom
of the screen, I seem to not be able to view the contents of the
variables
that were declared as static?

ex: if I declared a variable like this:

static int cxClient;

and then during the WM_SIZE handler i would like to view cxClient's
value
during a debug session like so:

case WM_SIZE:
cxClient = LOWORD (lParam); //I would like to see the variables
value!!!
cyClient = HIWORD (lParam);
...
...Other code

But I see all other variables except the ones that were declared
'static'.
Also I can add variables to the Quick watch window, but I can only see
the
value of a normal variable but not a static one?

Basically, when I run my app, I click on :

Build> start debug> go

Then the variables screens come on at the bottom of the screen... and
as I
say, I can't see any of the variables which are declared static.

Can anyone help me ?

Thanking you in advance!

--
Best regards
Robert
--
Best regards
Robert






.



Relevant Pages

  • Re: Why cant I see static variables in debug window
    ... Paul T. ... HDC hdc; ... Auto pane of the variable window, because you're about to use it (to ... you can use the Locals pane to see everything... ...
    (microsoft.public.windowsce.embedded)
  • Re: Why cant I see static variables in debug window
    ... Hey Paul, I really want to beleive you man! ... HDC hdc; ... Auto pane of the variable window, because you're about to use it (to add ... you can use the Locals pane to see everything... ...
    (microsoft.public.windowsce.embedded)
  • Re: Why cant I see static variables in debug window
    ... Not only don't I see x in the local debug window but I don't see in the auto ... Best regards ... If you change the variables window to show Locals, ...
    (microsoft.public.windowsce.embedded)
  • Re: Logoff / Slow Bootups / Outlook attachements / Outlook Not res
    ... With regards to trying the administrator log on this problem only actually ... click to check the "Hide All Microsoft Services" ... Click OK to close the MSConfig window. ... attach. ...
    (microsoft.public.windows.server.sbs)
  • Fehribach to Guido
    ... window. ... Her software was front, novel, and regards next to the ... jurisdiction. ...
    (sci.crypt)