tn
Hello Rod
These are my findings. Hope it helps (probably not though:). Nfo view app works normally written this way. Check it
highlight.asm
----------CODE START------------
.386
.model flat,stdcall
option casemap:none
include higlight.inc
.code
start:
invoke GetModuleHandle,NULL
mov hInstance,eax
invoke GetCommandLine
invoke InitCommonControls
mov CommandLine,eax
invoke WinMain,hInstance,NULL,CommandLine,SW_SHOWDEFAULT
invoke ExitProcess,eax
WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
LOCAL wc:WNDCLASSEX
LOCAL msg:MSG
mov wc.cbSize,sizeof WNDCLASSEX
mov wc.style,CS_HREDRAW or CS_VREDRAW
mov wc.lpfnWndProc,offset WndProc
mov wc.cbClsExtra,NULL
mov wc.cbWndExtra,DLGWINDOWEXTRA
push hInst
pop wc.hInstance
mov wc.hbrBackground,COLOR_BTNFACE+1
mov wc.lpszMenuName,NULL
mov wc.lpszClassName,offset ClassName
invoke LoadIcon,NULL,IDI_APPLICATION
mov wc.hIcon,eax
mov wc.hIconSm,eax
invoke LoadCursor,NULL,IDC_ARROW
mov wc.hCursor,eax
invoke RegisterClassEx,addr wc
invoke CreateDialogParam,hInstance,IDD_DIALOG,NULL,addr WndProc,NULL
invoke ShowWindow,hWnd,SW_SHOWNORMAL
invoke UpdateWindow,hWnd
.while TRUE
invoke GetMessage,addr msg,NULL,0,0
.BREAK .if !eax
invoke TranslateMessage,addr msg
invoke DispatchMessage,addr msg
.endw
mov eax,msg.wParam
ret
WinMain endp
WndProc proc hWin:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM
mov eax,uMsg
.if eax==WM_INITDIALOG
push hWin
pop hWnd
invoke FindResource,hInstance,ID_RCDATA,RT_RCDATA
invoke LoadResource,hInstance,eax
invoke LockResource,eax
invoke SetDlgItemText,hWin,ID_EDIT,eax
.elseif eax==WM_CLOSE
invoke DestroyWindow,hWin
.elseif uMsg==WM_DESTROY
invoke PostQuitMessage,NULL
.else
invoke DefWindowProc,hWin,uMsg,wParam,lParam
ret
.endif
xor eax,eax
ret
WndProc endp
----------CODE END---------------
end start
highlight.inc
------------CODE START-------------
include windows.inc
include user32.inc
include kernel32.inc
include shell32.inc
include comctl32.inc
include comdlg32.inc
includelib user32.lib
includelib kernel32.lib
includelib shell32.lib
includelib comctl32.lib
includelib comdlg32.lib
WinMain PROTO :DWORD,:DWORD,:DWORD,:DWORD
WndProc PROTO :DWORD,:DWORD,:DWORD,:DWORD
IDD_DIALOG equ 1000
ID_EDIT equ 1001
ID_RCDATA equ 2000
.const
ClassName db 'DLGCLASS',0
AppName db 'Dialog as main',0
AboutMsg db 'MASM32 RadASM Dialog as main',13,10,'Copyright © MASM32 2001',0
.data?
hInstance dd ?
CommandLine dd ?
hWnd dd ?
--------------CODE END-----------------
highlightDlg.Rc
-------------CODE START-------------
#define IDD_DIALOG 1000
#define IDC_EDT1 1001
IDD_DIALOG DIALOGEX 0,0,216,305
CAPTION "nfo viewer"
FONT 6,"Terminal",400,0
CLASS "DLGCLASS"
STYLE 0x10CB0880
EXSTYLE 0x00000001
BEGIN
CONTROL "",IDC_EDT1,"Edit",0x503109C4,0,0,216,305,0x00000200
END
-----------CODE END---------------------------
Interesting problem, I don't know what's the answer to it. From my expirience I don't use DialogBoxParam but a combination WinMain & CreateDialogParam because there is always some kind of problem with it. I made this code with assistance of RadAsm visual assembler.
Stiles used
---------- window -----------
border = MODALFRAME
child = FALSE
clipping = NONE
enabled = TRUE
font = terminal, 6, regular
left = 0
top = 0
right = 330
bottom = 330
sysmenu = TRUE
scrollbar = NONE
--------- edit control --------
autoscroll = BOTH
border = 3D-Look
left = 0
top = 0
right = 324
bottom = 305
locked = TRUE
multiline = TRUE
scrollbar = BOTH
I am avare that I didn't answer your question. I wanted to look for this occurance with a different type of dialog app which I often use. These are just the results of my test.
I added the whole RadAsm project in .zip archive (6k).
keep it kewl,
Markec
Edit..............
I think that a dialog proc with DalogBoxParam doesn't use the classname for the window. If you make this app with CrateDialogParam, then you have to define classname for the window as it follows from the example above
IDD_DIALOG DIALOGEX 0,0,216,305
CAPTION "nfo viewer"
FONT 6,"Terminal",400,0
CLASS "DLGCLASS" <<<<<<<<<<<<< here is the class
STYLE 0x10CB0880
EXSTYLE 0x00000001
You should check out the Iczelion's tutorials which you can download from his webpage
http://win32asm.cjb.net/
Markec
[attachment deleted by admin]
DialogBoxParam and DialogBoxIndirectParam create a dialog with the window class name "#32770". And for the one working example of CreateDialogParam (\MASM32\examples\exampl05\nova) that I found, the window class name is also "#32770", so I assume CreateDialogIndirectParam does the same. The page here (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msaa/msaapndx_49q0.asp) makes no mention of how the dialog was created.
tnx for the help on the this but us there no way to get rid of the keyboard focus. Someone menationed sometime ago it could be fixed with
Quote
I had the same problem as you with the text. I resolved the issue by changing the tabstop order on the dialog, so that the edit control was not the first stop
but i am unsure as to how to do this. The only problem with me doing it that way is i already have a winmain and a wndproc this program would be apart of another program.
j
Like I already said - I don't like DialogBoxParam function. There is "allways" some problem with it. At least in the example with CreateDialogParam you get an idea what's going on, soI like it better. And there are no problems with it, like with this highlighting of the text.
What classname is concerned, it must be somekind of a default value for DialogBoxParam (Indirect probably have a different one) because when you code this dialog app in RadAsm the Classname entry in the dialog resource stays blank. The problem begins only when you try to put something for it. The usual is that the window is in show state, but it can't be selected,
As you can see in the Iczelion's Dialog box as the main window tutorial for the file dialog.rc
----------- CODE START -----------------
#include "resource.h"
#define IDC_EDIT 3000
#define IDC_BUTTON 3001
#define IDC_EXIT 3002
#define IDR_MENU1 3003
#define IDM_GETTEXT 32000
#define IDM_CLEAR 32001
#define IDM_EXIT 32003
MyDialog DIALOG 10, 10, 205, 60
STYLE 0x0004 | DS_CENTER | WS_CAPTION | WS_MINIMIZEBOX |
WS_SYSMENU | WS_VISIBLE | WS_OVERLAPPED | DS_MODALFRAME | DS_3DLOOK
CAPTION "Our Second Dialog Box"
MENU IDR_MENU1
BEGIN
EDITTEXT IDC_EDIT, 15,17,111,13, ES_AUTOHSCROLL | ES_LEFT
DEFPUSHBUTTON "Say Hello", IDC_BUTTON, 141,10,52,13
PUSHBUTTON "E&xit", IDC_EXIT, 141,26,52,13
END
IDR_MENU1 MENU
BEGIN
POPUP "Test Controls"
BEGIN
MENUITEM "Get Text", IDM_GETTEXT
MENUITEM "Clear Text", IDM_CLEAR
MENUITEM "", , 0x0800 /*MFT_SEPARATOR*/
MENUITEM "E&xit", IDM_EXIT
END
END
--------- CODE END ------------------
there is no classname entry. And, if you don't mind me asking, why would you want to change the class name? And why not use the CreateDialogParam? It obviously works "niicer". At least for me, that is.
Greets,
Markec
aye the classname is a bit irrelevant :P is there anyway to get the program to open ad a child window meaning nothing shows up on the start menu maybe that would fix i dont know. I'm just lloking for a way to fix the problem with the code.
Quote from: rodderswank on December 03, 2005, 11:28:02 PM
tnx for the help on the this but us there no way to get rid of the keyboard focus. Someone menationed sometime ago it could be fixed with
Quote
I had the same problem as you with the text. I resolved the issue by changing the tabstop order on the dialog, so that the edit control was not the first stop
but i am unsure as to how to do this. The only problem with me doing it that way is i already have a winmain and a wndproc this program would be apart of another program.
Yes, it seems tha this does fix the problem. A new problem arizes. It appears that you have to have a secont control (like a buttob) to wich you could assign the tab stop index to a lover valu than the edit box has. I tried disabling tab stop for the edit box, but it didn't produce any resaults. The edit box has to be at least the second in the row for the tab stop to work.
In this example the button is first in line
------ CODE START --------------------
#define IDD_DLG1 101
#define IDC_EDT1 1001
#define IDC_BTN1 1002
IDD_DLG1 DIALOGEX 0,0,214,303
CAPTION "nfo view"
FONT 6,"Terminal",400,0
STYLE 0x10CD0080
EXSTYLE 0x00000001
BEGIN
CONTROL "",IDC_EDT1,"Edit",0x503029C4,0,0,158,300,0x00000200
CONTROL "IDC_BTN",IDC_BTN1,"Button",0x50010000,168,78,36,40,0x00000000
END
------- CODE END -------------------
and here the button is second
------------- CODE START -------------------
#define IDD_DLG1 101
#define IDC_EDT1 1001
#define IDC_BTN1 1002
IDD_DLG1 DIALOGEX 0,0,214,303
CAPTION "nfo view"
FONT 6,"Terminal",400,0
STYLE 0x10CD0080
EXSTYLE 0x00000001
BEGIN
CONTROL "IDC_BTN",IDC_BTN1,"Button",0x50010000,168,78,36,40,0x00000000
CONTROL "",IDC_EDT1,"Edit",0x503029C4,0,0,158,300,0x00000200
END
---------------------- CODE END---------------
As it seems, only the order in the file for the control has chagnged, which leads me to the conclusion: the control that's on the bottom of the file is first for the tab stop. Does this make sense? I don't know.
Furthermore, it is enough to add a second control to the dialog so the text won't be highlighted any more.
Aaaaaaahh, now I got it. You can do it like this
-------------- CODE sTART -----------
#define IDD_DLG1 101
#define IDC_BTN1 1002
#define IDC_EDT1 1001
IDD_DLG1 DIALOGEX 0,0,214,303
CAPTION "nfo view"
FONT 6,"Terminal",400,0
STYLE 0x10CD0080
EXSTYLE 0x00000001
BEGIN
CONTROL "IDC_BTN",IDC_BTN1,"Button",NOT 0x10000000|0x40010000,168,78,36,40,0x00000000
CONTROL "",IDC_EDT1,"Edit",0x503029C4,0,0,214,300,0x00000200
END
----------------- CODE END ---------------------
in this case the button's visible property is set to FALSE and it's behind the edit control. So it is invisible (in addition to having the tab stop order lover then the edit box). Not a very clean way, but it works
Markec
Quote from: rodderswank on December 03, 2005, 11:58:05 PM
aye the classname is a bit irrelevant :P is there anyway to get the program to open ad a child window meaning nothing shows up on the start menu maybe that would fix i dont know. I'm just lloking for a way to fix the problem with the code.
I think that the edit box on a dialog is by defaul a child window of the original dialog. And by setting the child window property you only establish the the clipping order and the fact that children windows must be destroyed when the parent window is destroyed.
Try this method from the previos post. Basically, you should put the edit control to the bottom of the file, and change the stile 0x50000000 (visible = TRUE) to 0x40000000 (visible = FALSE) for an invisible control (assuming tha you want to have only an edit box in the dialog) which can be a stati or a button, or another edit control.
Greets,
Markec
i cant fix it i i dont how how i could incorporate your code above into my current winmain/wndproc
mkey could i send u my project file and maybe you could have a llok at it if it wouldnt be too much hassle? or does any1 else have any ideas on how it could be fixed?
Quote from: rodderswank on December 04, 2005, 12:25:37 AM
mkey could i send u my project file and maybe you could have a llok at it if it wouldnt be too much hassle? or does any1 else have any ideas on how it could be fixed?
Hi rodder,
you can if you want, by you should try it your self first.
You should do this (your code in black, added code in red)
----------------- CODE START ------------------
#define DS_SETFONT 0x40L
#define DS_MODALFRAME 0x80L
#define WS_CAPTION 0x00C00000L
#define WS_SYSMENU 0x00080000L
#define ES_MULTILINE 0x00000004L
#define ES_AUTOVSCROLL 0x00000040L
#define ES_AUTOHSCROLL 0x00000080L
#define ES_READONLY 0x00000800L
#define WS_VSCROLL 0x00200000L
#define IDD_DIALOG1 101
#define IDC_EDIT1 1001
#define IDR_NFO1 2001
IDD_DIALOG1 DIALOGEX 0, 0, 330, 300
STYLE DS_SETFONT | DS_MODALFRAME | WS_CAPTION | WS_SYSMENU
CAPTION "nfo view"
FONT 6, "Terminal", 400, 0, 0xFF
BEGIN
PUSHBUTTON "some text", IDC_BUTTON, 0,0,0,0
EDITTEXT IDC_EDIT1,0,0,330,300,ES_MULTILINE | ES_AUTOVSCROLL |
ES_AUTOHSCROLL | WS_VSCROLL | ES_READONLY
END
IDR_NFO1 RCDATA "test.NFO"
--------------- CODE END ------------------
As long it's first in the file it should have a tab stop presedance over the edit box (at least in RadAsm). If it doesnt work, you can allways put something like this in your code, under the WM_INITDIALOG
------ CODE START --------------
....
GetDlgItem,hDlg,IDC_BUTTON ;<<<<<<<<<< hDlg is a hande to your dialog, IDC_BUTTON the button id, obviously
SetFocus,eax
.......
------ CIODE END ------------
This shoul het the focus out of the way, and since the button hase a size of zero, it isn't visible. A littlebit messy, but it works
And you could change from the DialogBOxParam to the CreateParamDialog. You can se tha the strucutre of these codes is tha same. The both have DlgProc, you just have to add some code (for the menu, a class name and so on)
Greets,
Markec
Thats sorted it thank you very much :) 1 last thing if its not too much trouble would it be possible for when that code is executed nothing shows up on the taskbar/start and when in viewing an nfo the mouse cursor doesnt show when toggled over the nfo. Also how would i remove the top border so theres no blue top border?
Quote from: rodderswank on December 04, 2005, 09:49:06 AM
1 last thing if its not too much trouble would it be possible for when that code is executed nothing shows up on the taskbar/start
Why would you want to hide the fact that someone was looking at was essentially a text file?
In XP it it simple, right click the item in the start menu, select "remove from list". :green2
Quote from: rodderswank on December 04, 2005, 09:49:06 AM
Also how would i remove the top border so theres no blue top border?
Change the window style.
Quote from: rags on December 04, 2005, 11:07:51 AM
Quote from: rodderswank on December 04, 2005, 09:49:06 AM
1 last thing if its not too much trouble would it be possible for when that code is executed nothing shows up on the taskbar/start
Why would you want to hide the fact that someone was looking at was essentially a text file?
In XP it it simple, right click the item in the start menu, select "remove from list". :green2
Quote from: rodderswank on December 04, 2005, 09:49:06 AM
Also how would i remove the top border so theres no blue top border?
Change the window style.
yes but iw ould like it so you cant click on the startmenu
Quote
yes but iw ould like it so you cant click on the startmenu
What does this mean? I dont understand. And like rags said, you can set window styles in such a manner that there is no footprint of the program on the taskbar (make it a toolwindow style, but be aware, it's not comaptible with some styles - examine the api help file for details) or no border (style boarder 0x0080000).
Greets,
Markec
ive just tried both those styles they dont seem to do anything
Hi, rodder
you should REALLY start to use your Win32 Programmer's Reference. There it states
------------ REFERENCE START ---------------
ShowCursor
The ShowCursor function displays or hides the cursor.
int ShowCursor(
BOOL bShow // cursor visibility flag
);
Parameters
bShow
Specifies whether the internal display counter is to be incremented or decremented. If bShow is TRUE, the display count is incremented by one. If bShow is FALSE, the display count is decremented by one.
Return Values
The return value specifies the new display counter.
Remarks
This function sets an internal display counter that determines whether the cursor should be displayed. The cursor is displayed only if the display count is greater than or equal to 0. If a mouse is installed, the initial display count is 0. If no mouse is installed, the display count is -1.
------------------ REFERENCE END -------------------
Therefore, if you use something like this
...
ShowCursor,FALSE
...
The cursor should be hidden since the cursor counter by default is NULL, and to hide the cursor you need to set it to a nuber lover then NULL (which is set by the FALSE flag).
As far the toolwindow style, you should try this
---------------- REFERENCE START ------------------
WS_EX_TOOLWINDOW Creates a tool window; that is, a window intended to be used as a floating toolbar. A tool window has a title bar that is shorter than a normal title bar, and the window title is drawn using a smaller font. A tool window does not appear in the taskbar or in the dialog that appears when the user presses ALT+TAB.
----------------- REFERENCE END --------------------
You should use it as an extra style, and then it must work. At least it does work with CreateDialogParam and CreateWindowEx.
Greets,
Markec
Hi, rod
here you go
Greets
Markec
[attachment deleted by admin]