- Отметить как новое
- Закладка
- Подписаться
- Отключить
- Подписка на RSS-канал
- Выделить
- Печать
- Сообщить о недопустимом содержимом
Hi All,
I have a "type (T_RECT) rectp" defined and I'm in a WM_PAINT section in an SDI window. I've created a brush as " hBrush = GetStockObject(WHITE_BRUSH)". I've populated the rect by "bret = GetClientRect(hWndMain, rectp)". All the values look good in the debug window but the program crashes at the statement "iret = FillRect ( hDC, rectp, hBrush)" with the message "Unhandled exception at 0x00007FF7DDFB1CD6 in Pearson.exe: 0xC000041D: An unhandled exception was encountered during a user callback.". I am running Intel Fortran 2016.1.146 in x64 mode on a Win 10 x64 OS.
Any ideas what is wrong here?
Thanks,
Brooks V
- Отметить как новое
- Закладка
- Подписаться
- Отключить
- Подписка на RSS-канал
- Выделить
- Печать
- Сообщить о недопустимом содержимом
Both of those should be of type integer(handle)
In VS
Configuration Properties > Fortran > Diagnostics
at the cmd line it is \warn:interfaces
It will show and mismatched types call parameters which is one possible cause.
Ссылка скопирована
- Отметить как новое
- Закладка
- Подписаться
- Отключить
- Подписка на RSS-канал
- Выделить
- Печать
- Сообщить о недопустимом содержимом
I forgot to mention that I'm on an ASUS computer with 32GB RAM with an Intel(R) Core(TM) i7-4770 CPU at 3.40GHz processor with 4 cores and hyper-threading turned on.
Brooks V
- Отметить как новое
- Закладка
- Подписаться
- Отключить
- Подписка на RSS-канал
- Выделить
- Печать
- Сообщить о недопустимом содержимом
Do you have "check interfaces compiler" option on? How are hDC and hbrush declared?
- Отметить как новое
- Закладка
- Подписаться
- Отключить
- Подписка на RSS-канал
- Выделить
- Печать
- Сообщить о недопустимом содержимом
where do i check on 'check interfaces'? hDC = GetDC(hWndMain) and hBrush = GetStockObject(WHITE_BRUSH). I've already done some TextOut and MoveTo/LineTo commands without any errors.
Brooks V
- Отметить как новое
- Закладка
- Подписаться
- Отключить
- Подписка на RSS-канал
- Выделить
- Печать
- Сообщить о недопустимом содержимом
Both of those should be of type integer(handle)
In VS
Configuration Properties > Fortran > Diagnostics
at the cmd line it is \warn:interfaces
It will show and mismatched types call parameters which is one possible cause.
- Отметить как новое
- Закладка
- Подписаться
- Отключить
- Подписка на RSS-канал
- Выделить
- Печать
- Сообщить о недопустимом содержимом
Yes they all are integers:
integer(HANDLE),Save,public:: hInst
integer(HANDLE),Save,public:: hWndDlg
integer(HANDLE),Save,public:: hWndMain
Integer(HANDLE),Save,public:: hPen = NULL, hOldPen = NULL
Integer(HANDLE),Save,public:: hBrush = NULL, hOldBrush = NULL
Integer(HANDLE),Save,public:: hMyFont36 = NULL, hOldFont = NULL
Integer(HANDLE),Save,public:: hMyFont12= NULL, hMyFont16 = NULL
Integer(HANDLE),Save,public:: hMyFont20 = NULL, hMyFont24= NULL
Integer(HANDLE),Save,public:: hDlg = NULL
Integer(HANDLE),Save,public:: hDC = NULL
- Отметить как новое
- Закладка
- Подписаться
- Отключить
- Подписка на RSS-канал
- Выделить
- Печать
- Сообщить о недопустимом содержимом
Andrew,
Both places already had the warn:interfaces set so that is a dead end.
Thanks anyway,
Brooks V
- Отметить как новое
- Закладка
- Подписаться
- Отключить
- Подписка на RSS-канал
- Выделить
- Печать
- Сообщить о недопустимом содержимом
Well that is a couple of avenues closed
did you call selectobject to bring the brush unto the current device context? Posting some code might shed some light....
- Отметить как новое
- Закладка
- Подписаться
- Отключить
- Подписка на RSS-канал
- Выделить
- Печать
- Сообщить о недопустимом содержимом
Does your callback routine include !DEC$ ATTRIBUTES STDCALL? On IA-32, all Windows callbacks must be STDCALL. (Add REFERENCE if you want that, and include the same directive where the callback routine is declared for use in the call.
Also, check to see if you made the same mistake I made once upon a time.
- Отметить как новое
- Закладка
- Подписаться
- Отключить
- Подписка на RSS-канал
- Выделить
- Печать
- Сообщить о недопустимом содержимом
The program was generated by the SDI code wizard. It is:
integer*4 function WinMainProc(hMain, message, wParam, lParam)
!DEC$ ATTRIBUTES STDCALL, ALIAS : 'WinMainProc' :: WinMainProc
No Win32 but I'm using X64 settings/
Brooks V
- Отметить как новое
- Закладка
- Подписаться
- Отключить
- Подписка на RSS-канал
- Выделить
- Печать
- Сообщить о недопустимом содержимом
case (WM_PAINT)
if (last == -1) Then
hDC = GetDC(hWndMain)
type *, 'WinMainProc:: WM_PAINT hDC = ', hDC
hOldFont = SelectObject(hDC,hMyFont12)
end if
if ((last == myOption) .or. (maxx == 0)) Then
WinMainProc = 0
return
End If
type *, 'WinMainProc:: WM_PAINT Entering'
! last = myOption
if (hDC == NULL) Then
type *, 'WinMainProc:: Cannot get hDC in WM_PAINT'
WinMainProc = 0
return
End If
nx = Rectxy%right - Rectxy%left
ny = Rectxy%bottom - Rectxy%top
type *, 'WinMainProc:: in WM_PAINT with nx, ny =', nx, ny
if ((rectp%bottom /= 0) .and. (hBrush /= NULL)) Then
! iret = FillRect ( hDC, rectp, hBrush)
end if
Debug output after commenting the FillRect call out.
Creating MainWindow
WinMainProc:: WM_CREATE Entering
WinMainProc:: WM_CREATE hPen = 28311575
WinMainProc:: WM_CREATE hBrush = 26214416
WinMainProc:: WM_CREATE hMyFont12 = 302655804
WinMainProc:: WM_CREATE hMyFont16 = -1039523558
WinMainProc:: WM_CREATE hMyFont20 = -284546895
WinMainProc:: WM_CREATE hMyFont24 = 1493837148
WinMainProc:: WM_CREATE hMyFont36 = 1510611582
WinMainProc:: WM_CREATE Leaving
>>>>>>>> WinMain Showing window
WinMainProc:: WM_SIZE Entering
WinMainProc:: WM_SIZE Leaving
Beginning Dialog processing
SetUpMyDlg:: DlgSetSub(IDD_PMAIN) RC = T
SetUpMyDlg:: DlgSetSub(IDC_FIT) RC = T
SetUpMyDlg:: DlgSetSub(IDC_SAMP) RC = T
SetUpMyDlg:: DlgSetSub(IDC_PCTYPE) RC = T
SetUpMyDlg:: CheckBoxDisabled(IDC_RAND) RC = T
SetUpMyDlg:: CheckBoxDisabled(IDC_SAVE) RC = T
SetUpMyDlg:: EditBoxChanged(IDC_RSSIZE) RC = F
SetUpMyDlg:: LabelChanged(IDC_RSLAB) RC = T
SetUpMyDlg:: EditboxDisAbled(IDC_FNAME) RC = T
SetUpMyDlg:: LabelDisAbled(IDC_FNAME) RC = T
SetUpMyDlg:: DlgModeless RC = T
SetUpMyDlg:: DlgSET(IDC_PCTYPE) RC = T
SetUpMyDlg:: DlgSET(IDC_MYSPIN) RC = T
SetUpMyDlg:: CheckRadioButton[Set](IDC_CENTRAL) RC = T
SetUpMyDlg:: DlgSetInt(IDC_MYSPIN,0,RangeMin) RC = T
SetUpMyDlg:: DlgSetInt(IDC_MYSPINL,8,RangeMax) RC = T
SetUpMyDlg:: DlgSrtInt(IDC_MYSPIN,0,Position) RC = T
SetUpMyDlg:: SetDlgItemText(IDC_PCTYPE,myBuffer) RC = T
SetUpMyDlg:: SetDlgItem(IDC_M1) RC = T
SetUpMyDlg:: SetDlgItem(IDC_M2) RC = T
SetUpMyDlg:: SetDlgItem(IDC_M3) RC = T
SetUpMyDlg:: SetDlgItem(IDC_M4) RC = T
SetUpMyDlg:: RadioChanged(IDC_STATISTICS) RC = T
SetUpMyDlg:: RadioChanged(IDC_PDF) RC = T
SetUpMyDlg:: RadioChanged(IDC_CDF) RC = T
SetUpMyDlg:: RadioChanged(IDC_HIST) RC = T
SetUpMyDlg:: RadioChanged(IDC_MORESTAT) RC = T
Dialog is up and running T
Maxx, Maxy = 1735 996
RectDialog (L,T,R,B) = 0 0 184 997
RectParent (L,T,R,B) = 184 0 1736 997
RectGeneral (L,T,R,B) = 194 10 1726 987
RectDrawing (L,T,R,B) = 60 60 1676 937
WinMainProc:: WM_PAINT hDC = -2113854287
WinMainProc:: WM_PAINT Entering
WinMainProc:: in WM_PAINT with nx, ny = 1616 877
WinMainProc:: WM_PAINT Leaving
WinMainProc:: WM_MOUSEMOVE ==>
Mouse at 618 99
@@@@@@@@@@@@@@@@@@@@@ I don't see why I needed to put the hBrush into the hDC with SelectObject because I'm sending the hBrush to the hDC in the FillRect call.
- Отметить как новое
- Закладка
- Подписаться
- Отключить
- Подписка на RSS-канал
- Выделить
- Печать
- Сообщить о недопустимом содержимом
No pair of BeginPaint/EndPaint calls?
- Отметить как новое
- Закладка
- Подписаться
- Отключить
- Подписка на RSS-канал
- Выделить
- Печать
- Сообщить о недопустимом содержимом
Correct. This is not Windows 3.1 anymore. There is no good reason to get a DC for a few things and then release it immediately. I am running a x64 application on an x64 OS with 32 GB of RAM.
Brooks V
- Отметить как новое
- Закладка
- Подписаться
- Отключить
- Подписка на RSS-канал
- Выделить
- Печать
- Сообщить о недопустимом содержимом
In all cases, an application can draw in a window as soon as it is created. To draw in the window, the application must first retrieve a handle to a display device context for the window. Ideally, an application carries out most of its drawing operations during the processing of WM_PAINT messages. In this case, the application retrieves a display device context by calling the BeginPaint function. If an application draws at any other time, such as from within WinMain or during the processing of keyboard or mouse messages, it calls the GetDC or GetDCEx function to retrieve the display DC.
I don't believe the begin/end paint call are optional. But I may be wrong.......
- Отметить как новое
- Закладка
- Подписаться
- Отключить
- Подписка на RSS-канал
- Выделить
- Печать
- Сообщить о недопустимом содержимом
I can and do draw both text and graphics to my window withoug the paint structures.
Brooks V
- Отметить как новое
- Закладка
- Подписаться
- Отключить
- Подписка на RSS-канал
- Выделить
- Печать
- Сообщить о недопустимом содержимом
The Begin/EndPaint pair updates windows internal data structures that track things such as the clipping region associated with the visible extent of the window and the update rectangle. Getting a DC, and the ability to do drawing into a DC at arbitrary times, is somewhat incidental to this. Certainly for versions of Windows <= Windows XP (so including versions well past Windows 3.1) failure to call that pair appropriately in a WM_PAINT message (or otherwise update the data structures) will result in strangeness. I wouldn't regard it as optional.
- Отметить как новое
- Закладка
- Подписаться
- Отключить
- Подписка на RSS-канал
- Выделить
- Печать
- Сообщить о недопустимом содержимом
.... you normally get a paint as part of the region is invalidated. If you don't Begin/EndPaint that itch doesn't get scratched and windows will keep throwing WM_PAINT messages.....
and I second Ian's words of wisdom.

- Подписка на RSS-канал
- Отметить тему как новую
- Отметить тему как прочитанную
- Выполнить отслеживание данной Тема для текущего пользователя
- Закладка
- Подписаться
- Страница в формате печати