|
|
Since this is MFC - you don't really need global variables. That is because the MFC framework gives you one automatically - your application class. Just put anything of global scope in your application class (usually CYourProgramApp) and make appropriate accessor functions for it.
You can always get the app by calling AfxGetApp .
Or, as others have said, you can design your code so that it doesn't use globals...
If your nose runs and your feet smell, then you're built upside down.
|
|
|
|
|
Hi All,
I would like to know how the File Handling APIs provided by Windows are passed on to the NTFS driver. What are the various layers through which these API calls are taken before the file system driver actually converts it into low level system calls. Suppose I want to programmatically open a file in C++, then I would make a call to OpenFile() method provided by Win SDK. Then, what are the various stages before the call is actually taken by the file system driver. Do we have any control at the driver stage of the call?
Please help,
Abhishek.
Learning is a never ending process of Life.
|
|
|
|
|
first lection for
abhinarulkar wrote:
Learning is a never ending process of Life.
... you call CreateFile and NOT OpenFile!
the call is passed via interrupt 2e to the kernel, then to the io manager, cache manager, file system, storage class driver, something like that
Don't try it, just do it!
|
|
|
|
|
Hi,
I meet an exception "Float Invalid Opration" and to debug, jump into "Disassembly Window" and "Call Stack Window" in "ntdll.dll". I do not know which function throw the exception, how can I know it?
Which reasons cause the "Float Invalid Opration", in general? How can I get
rid of it?
Thanks a lot!
|
|
|
|
|
Run the program in Debug mode( press F5 ), and when an exception is raised, just right click anywhere on the toolbar( without stopping the program ), and select the 'CallStack' option from the menu. Now you will be able to see the stack for the program.
"A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."
|
|
|
|
|
Hello, Sir:
I have a matter with the floating point arithmetics test. And I have some function that was write assembler language. But I want to realization it on VC++. I don't how to do. And I have tried, but i can't success, Because i don't what those assembler is means. Can you help me?
The Source Code :
CARRY_ERROR EQU 1
REG_BITS_ERROR EQU 2
FLAGS_ERROR EQU 3
BCD_ERROR EQU 4
MUL_DIV_ERROR EQU 5
JMP_ERROR EQU 6
MUL386_ERROR EQU 7
LOGIC1_ERROR EQU 8
LOGIC2_ERROR EQU 9
CMPS_ERROR EQU 10
IOS_ERROR EQU 11
STRS_ERROR EQU 12
MOVS_ERROR EQU 13
PUSHA_ERROR EQU 14
NUM_REG = 8 ; NUMBER OF REGISTERS IN THE NPX
NUM_BITS = 64 ; # of bits to test in the significant
NUM_EXP = 14 ; # of bits to test in the exponent
;*****************************************************************************
;_ChkFpuArith
; Test FPU Arithmetics
; Entry: None
; Exit: AX=1 if PASS , AX=0 if Fail
;*****************************************************************************
PUBLIC _ChkFpuArith
_ChkFpuArith PROC far
push ds
push es
push bx
push si
push di
mov ax,CPUGROUP
mov ds,ax
finit ; initialize the npx
cli ; disable intrerrupts. then load the
mov control_word,133fh ; ctrl word: no exceptions, no interrupts
fldcw control_word ; 64 bits, round even, infinity affine
mov reg_counter,num_reg ; for each register do:
t001:
fild ds:two ; initialize register
mov bit_counter,num_bits ; for each bit in the significand field:
t002:
call check_significand ; if carry bit not set, flag error
jc short t004 ; and return
fimul ds:two ; generate carry (register*2)
fisub ds:one ; move bit to the right (register-1)
dec bit_counter
jnz short t002 ; end for
fstp st(0) ; initialize register (store and pop)
fild ds:four ; integer load 4
mov bit_counter,num_exp ; for each bit in the exponent field do:
t003:
call check_exponent ; if exponent incorrect, return
jc short t004 ;
fmul st,st(0) ; squares the content of the stack top
fidiv ds:two ; divide by two, sets next bit in exponent
dec bit_counter
jnz short t003 ; end for
xor ax,ax ; zero expected condition bits.
call condition_bits ; if register <> positive & nonzero
t004:
jnz short t007 ; flag error and return
fchs ; generate a nan (sqrt(-number))
fsqrt
mov ah,045h ; set expected condition bits.
call condition_bits ; if register <> (nan or infinity)
jnz short t007 ; flag error and return
fstp st(0) ; store and pop. initialize register 0
fldz ; load +0.0 into stack 0
mov ah,040h ; set expected condition bits.
call condition_bits ; if register <> zero (+ or -)
jnz short t007 ; flag error and return
fsub ds:alarge ; make register negitive and nonzero
mov ah,001h ; set expected condition bits.
call condition_bits ; if register <> negitive and nonzero
jnz short t007 ; flag error and return
dec reg_counter ; endif
jz short t006 ;
jmp t001
t006:
call check_stack ; check each register for -large
jz short t008
t007:
mov ax,0
jmp @F
t008:
mov ax,1
@@:
sti
pop di
pop si
pop bx
pop es
pop ds
retf
_ChkFpuArith ENDP
condition_bits PROC near
ftst ; test stack top against 0.0, set condition bits
fstsw status_word ; store the status word
fwait ; wait for npx to finish
and status_word,4700h ; strip off all but the condition bits
cmp status_word,ax
ret
condition_bits ENDP
;
; check_significand
;
check_significand PROC near
mov ax,ds
mov es,ax
fsave full_npx_state ; put the npx reg stack in memory
frstor full_npx_state ; don't let npx re-initialize
fwait
xor al,al ; clear out the temporary buffer
mov di,offset temp_buff
mov cx,8
rep stos es:temp_buff
mov temp_buff+7,80h ; set bit 63
xor ah,ah ; calculate position of other bit
mov al,bit_counter ; divide by the # of bits in a byte
dec ax
mov bl,8
div bl ; divide by the # of bits in a byte
mov bx,ax
xor ah,ah
mov si,ax ; add byte offset of significand byte
mov al,bh ; translate the bit # to an actual
mov bx,offset ds:bit_table ; bit position
xlat ds:bit_table
or byte ptr temp_buff[si],al ; set bit in the temp_buff
mov si,offset temp_buff
mov di,offset byte ptr full_npx_state+14
mov cx,8
repe cmps temp_buff,byte ptr es:full_npx_state ; compare the two
jz short chk_sig_ok
stc ; Set carry flag is 1
jmp @F
chk_sig_ok:
clc ; Set carry flag is 0
@@:
ret
check_significand ENDP
;
; check_exponent
;
check_exponent PROC near
fsave full_npx_state ; put the npx reg stack in memory
frstor full_npx_state ; don't let npx re-initialize
fwait
mov si,22 ; save the exponent offset in the
mov al,num_exp ; index register. then calculate the
sub al,bit_counter ; corresponding bit position
mov bx,offset ds:bit_table ; load the address of the offset table
cmp al,8 ; if in next byte, then do:
jl short chk_ex_1
sub al,8
xlat ds:bit_table
mov ah,al
xor al,al
jmp short chk_ex_2
chk_ex_1:
xlat ds:bit_table
xor ah,ah
chk_ex_2:
or ax,04000h ; set non-fraction bit
fwait ; wait for npx to catch up
cmp full_npx_state[si],ax ; if exponent not equal, then
jz short chk_ex_3
stc
ret
chk_ex_3:
clc
ret
check_exponent ENDP
;
; check_stack
;
check_stack PROC near
mov ax,ds
mov es,ax
fsave full_npx_state ; get the register stack into the buffer
fwait
mov ax,8 ; eight registers to check
mov di,offset bptr full_npx_state+14
chk_stk_01:
mov si,offset ds:minus_large
mov cx,10 ; load a loop count for 10 bytes
rep cmps ds:minus_large,byte ptr es:full_npx_state
jnz short chk_stk_02
dec ax
jnz short chk_stk_01
chk_stk_02:
ret
check_stack ENDP
|
|
|
|
|
Hello,
I have an SDI application in wich I need several different views of the data. These views are not shown together (not a splitter window) but I need to use a button in the toolbar to switch to the different views.
How can I do that in a simple way?
Thanks
|
|
|
|
|
You can use tabs in a form view. There is an article in the Windows / Dialog section
http://www.codeproject.com/dialog/visualfx.asp
|
|
|
|
|
I found a much easier solution:
I have 2 member variables of CMainFrame (the 2 views):
CView* m_pScopeView;
CView* m_pXYView;
In CMainFrame::CreateClient, I do this:
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
CRect ClientRect;
GetClientRect(ClientRect);
m_pScopeView = (CView*)new CExtScopeView;
m_pScopeView->Create(NULL, NULL, WS_CHILD, CFrameWnd::rectDefault, this, SCOPE_VIEW, pContext);
m_pScopeView->OnInitialUpdate();
m_pXYView = (CView*)new CXYView;
m_pXYView->Create(NULL, NULL, WS_CHILD, ClientRect, this, XY_VIEW, pContext);
m_pXYView->OnInitialUpdate();
SetActiveView(m_pScopeView);
m_pScopeView->ShowWindow(SW_SHOW);
m_pXYView->SetDlgCtrlID(XY_VIEW);
m_pScopeView->SetDlgCtrlID(AFX_IDW_PANE_FIRST);
RecalcLayout();
return TRUE;
}
And when I select another view:
void CMainFrame::OnXYView()
{
SetActiveView(m_pXYView);
m_pXYView->ShowWindow(SW_SHOW);
m_pXYView->SetDlgCtrlID(AFX_IDW_PANE_FIRST);
m_pScopeView->ShowWindow(SW_HIDE);
m_pScopeView->SetDlgCtrlID(fActiveView);
RecalcLayout();
fActiveView = XY_VIEW;
}
This work fine exept that the toolbar is drawn 1 or 2 pixels under the normal position and so, there's no separating line between the toolbar and the form view. This is very ugly!
How can I avoid this ???
Thanks
|
|
|
|
|
You should not explicitly be calling OnInitialUpdate() you are asking for trouble there. You should write your own initializing funnction in this case. In addition this does not look like an easier solution to me - the link I have takes care of some of the details. SHOW_WINDOW is the key to switching between the views, but you still must map to the frame window and handle messages properly.
|
|
|
|
|
Ok, but I found this method in a book.
I forgot to tell you that I'm using FormViews.
I don't want to have a tab: the user must choose on the toolbar wich view he wants to be displayed. There is 3 totaly different form views.
So is there any simple way to create the 3 views at the same time (and initialize them) and then switch to the one the user select ??
Thanks for your help
|
|
|
|
|
What you were doing would work. Just put the showwindow in the handler from the button.
|
|
|
|
|
Yes that works, except that the toolbar is not draw correctly... This is really ugly !
I used the debugger and I saw that the CFrameWnd::rectDefault rectangle has strange values:
top and left = -2147483648
bottom and right = 0
Is that normal ???
|
|
|
|
|
I don't know - I wouldn't be doing what you are doing in the first place so it is difficult to say. I think it is flawed from the beginning.
Either avoid Doc/View entirely or expect problems when you tinker with it. You should try to make sure you add at least the view that was passed in the argument list in oncreateclient, for example, and use the class editor to try to add it to the framework. You should also test things like loading multiple times with different views, test the MDU etc, drag and drop functionality. Read up on the document templates as well. There is no really simple way to change it because it is set up to take the complex task of doc / view and throwing in some more views. It should be set up by Microsoft to be easier to add multiple views - but the fact is that it isn't.
|
|
|
|
|
Ok, I will try to look at all theses things !
Thanks a lot for your help
|
|
|
|
|
Hi all,
I want to open IE window with the URL i specify and also I want to position that window and define its height, width..can i do that..and if yes..how..can anyone show me some pointers or tutorials or ideas on this...
Thanks a lot in advance..
Himanshu
|
|
|
|
|
Use ShellExecute(...) API
"A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."
|
|
|
|
|
This might work, but you'll want to test it thoroughly in any case:
DWORD dwProcId;
HINSTANCE hInstance = ShellExecute(...);
hWnd = FindWindow(NULL, NULL);
while (NULL != hWnd)
{
if (GetParent(hWnd) == NULL)
{
if (hInstance == GetWindowThreadProcessID(hWnd, &dwProcId))
{
MoveWindow(hWnd, ...);
break;
}
}
hWnd = GetWindow(hWnd, GW_HWNDNEXT);
}
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Hi David,
Thanks a lot...but i cud not understand how to position the IE window and also how to define size of this IE window..Please help..
thanks a lot in advance
himanshu
|
|
|
|
|
Did you look at the MoveWindow() function? The parameters are self explanatory.
MoveWindows(..., left, top, width, height, ...);
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
hiii,
thanks a ton...i did that....
regards
Himanshu
|
|
|
|
|
Hi Guys,
I have an app in which I open a com port (9600, 8, N, 1, N (or H/W)) in overlapped mode to an external device. Whenever I write data to that port all data I sent is "echoed" back to me. After that I do get the device's data as expected, so the device is definately receiving the data. The device also does not have this "echo" capability, so it is not the device that is sending my own data back to me, so the problem lies somewhere in the driver, etc.
Is it perhaps the way in which the port is setup and opened ? Or it this a known issue in Windows serial driver ? Any other ideas ?
Regards
OD
|
|
|
|
|
I need to fill the array asfollows
const float feature_scal_intervall_low[NR_FEATURES] = {
0.1,0.0,0.1,0.1,0.3 ,0.2,0.1,0.1,0.0,0.2 };
Getting Warning : warning C4305: 'initializing' : truncation from 'const double' to 'const float'
How to typecast above array?? Any Suggesstions.
Thanks in advance
Warm Regards,
KKRam
|
|
|
|
|
Numbers written in 0.1 format are treated as doubles, to get he compiler to treat them as floats write them as 0.1f
Roger Allen
Sonork 100.10016
Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003
|
|
|
|
|