Conquest Posted May 2, 2015 Posted May 2, 2015 That's not really correct Conquest, each "message command" gets sent to a certain hWnd. They don't all get send to 1 place (besides frame/border/x buttons, dont think there's any "default handler" either).Each control has it's own hWnd - each hWnd has it's own callback handler.If I SendMessage(ListViewhWnd, WM_KEYDOWN,..) to ListView control, toplevel hWnd will not see it because they have diff. hWnd, different message handlers (current "problem")true. Beg your pardon . i was being careless with my words. What i meant was that windows gives 1st chance of handling the messages to the handler it was meant to . Also frame/borders etc are just images/vector and its the responsibility of underlying window class to handle the messages (for example the window recieves messages when they are being resized . Its the duty of windows itself to resize normal windows but what if you have a custom frame ?) @lcf-at i can suggest you to look at gtk if you want to code some gui decent enough at low level. I personally use nana pro but its high level c++11 stuff. i dont really like qt due to its being bloated hard (seriously ? 1 hello windows executable 7 mb . seriously qt?)
mrexodia Posted May 2, 2015 Posted May 2, 2015 (edited) ps - I'm not an expert, but I don't think the kernel has much to do w/GUI stuff. key/mouse move/press events start as IRP as scancodes, converted to virtual key codes, sent to user space via SendMessage based on mouse position, window focus, etc. Apart from native control's default msg handler, unhandled messages should just die on the stack. I believe all messages go through the kernel, especially because you can send messages to any HWND (including ones from other processes). pss - Qt is the way. Look at x64dbg, very high quality GUI w/main window in < 1k lines of code. It's not much less work than winapi, but it looks 10x better, no performance loss. only downside is ~3mb exe's, imo small price. Yea.. gui code is more like 30k lines. MainWindow.cpp is just a thing that hold every component together, but the real stuff is in the custom controls. Those become 1k lines each without effort. Tt would be at least 100 times as much with plain winapi though (probably a little better with MFC) @lcf-at i can suggest you to look at gtk if you want to code some gui decent enough at low level. I personally use nana pro but its high level c++11 stuff. i dont really like qt due to its being bloated hard (seriously ? 1 hello windows executable 7 mb . seriously qt?) It's true, Qt is bloated, but when you need a powerful GUI it's perfect. It also has a lot of custom classes and pre-made controls that make your life easier. The community is also very rich of applications and I wouldn't recommend anything else. Edited May 2, 2015 by Mr. eXoDia
simple Posted May 2, 2015 Posted May 2, 2015 (edited) mr X, I just meant the vast majority of GUI work happens in userspace.Yeah u created many custom widgets but the aesthetics part, your main layout shows how to simplify it and how nicely all comes together in a fairly brief code.Conquest, u dont have to beg me, but the only "Default handler" handles title bar, max/min/close button, and window drag. Remove that, there is no default, all must be done from scratch. In raw C winapi, this is what custom handler looks like. It's liek what Visual Studio does, but Id still need to draw GDI max/min/close buttons, align controls, etc (this woud look same on xp/7/8, etc) Edited May 2, 2015 by simple 1
LCF-AT Posted May 2, 2015 Author Posted May 2, 2015 Hi guys, thanks for your answers so far but I'am still confused.Normaly I don't wanna subclass anything and thought that I would also get ALL message commands as WM_KEYDOWN in my procederes if they get triggered but there I thought wrong (also didn't know this before) and now I should subclass anything what gets created (LV,LB,Edit etc) sounds more than ridiculous for me. I just wanna get ALL WM_xy etc in my procederes so what should I do now? So I could also make this code... start: invoke GetModuleHandle, NULL mov hInstance, eax ;invoke DialogBoxParam, hInstance, 101, 0, ADDR DlgProc, 0 invoke CreateDialogParam, hInstance, 101, 0, ADDR DlgProc, 0 mov hDlg, eax Loop_A: invoke GetMessage, ADDR msg, 0, 0, 0 .if eax != 0 SWITCH msg.message CASE WM_KEYDOWN nop nop ENDSW invoke TranslateMessage, ADDR msg invoke IsDialogMessage, hDlg, ADDR msg jmp Loop_A .endif invoke ExitProcess, eax ...and now I also get WM_KEYDOWN but the problem is that the actually datas will not send to my main proc parameters.... DlgProc proc hWin:DWORD,uMsg :DWORD,wParam:DWORD,lParam:DWORD ...and there I will not get WM_KEYDOWN.In that case I can just catch it above in the loop and then I can set a call to a other proc where I do change & modd & send my stuff + filling msg.message to zero (to prevent another change by system after my changes). So some coding stuff is really created very bad and the most time I do waste which such stupid stuff. greetz
Conquest Posted May 3, 2015 Posted May 3, 2015 (edited) It's true, Qt is bloated, but when you need a powerful GUI it's perfect. It also has a lot of custom classes and pre-made controls that make your life easier. The community is also very rich of applications and I wouldn't recommend anything else. I believe MFC offers something similar(to far lesser extent ofc,no networking and all those dedicated libraries. but its just a comparison of the gui features for the sake of the discussion) . The only complain about MFC of being outdated c++ styles. What i have figured out about qt is that the bloating occurs due to their custom engines for drawing and handling "stuff"(dont take my words granted, its only from my premature observation). I guess MFC/.net applications would been same kind of bloated if their libraries weren't already built into the windows(unfair advantage i know). Sorry for being offtopic but i couldnt resist stating my opinion. Edited May 3, 2015 by Conquest
mrexodia Posted May 3, 2015 Posted May 3, 2015 Yea, .NET framework is probably a few hundreds of megabytes and MFC isn't small either. The things those two don't give you is portability. Qt works on pretty much any operating system and/or device, which is another plus.
LCF-AT Posted May 4, 2015 Author Posted May 4, 2015 Hi again, ok I got it working now to subclass my Listviews with SetWindowLong API. Now I have a another little problem.As I said I have a Listview with any entrys inside and if I select any line then the entry of this line gets shown in a other static control so this is also working so far but only if I do check for WM_NOTIFY & NM_CLICK. uMsg == WM_NOTIFY mov ebx,lParam mov eax, (NM_LISTVIEW ptr [ebx]).hdr.code .if eax == NM_DBLCLK ...... ....... So I did subclass now all LVs and catch the WM_CHAR / WM_KEYDOWN in my new routine where I do check which key was pressed (a,b,c,1,2,3,etc) and then my code does compare the pressed key value with all first entrys in row 2 and if this also was found then I do change the selection to the new line.All working so far but the problem is that my static comtrol gets not updated so this only happens if I click the line with the mouse. My question now: Is there a way to send a fake WM_NOTIFY message & NM_DBLCLK message somehow so that on a next access on my main routine this messages get handled?You know what I mean right?So I don't wanna write this code a another time in my new routine and just thought I could send anyhow these 2 messages. Is there a simple way how to do this or not? greetz
simple Posted May 5, 2015 Posted May 5, 2015 Do u even search yourself before asking? It's on msdn...
LCF-AT Posted May 6, 2015 Author Posted May 6, 2015 Hi, nice answer simple!Of course I did so what's this for a strange question again? The only thing what I can do now to get some little success is to use the PostMessage API... invoke GetMessage,addr msg,hWndStore,0,0 mov msg.message, WM_NOTIFY mov msg.wParam, NM_CLICK invoke PostMessage,hWndStore,WM_NOTIFY,0,addr msg...problem in that case is that I need to create a extra MSG struct and using this with GetMessage API + hWndStore handle whats the handle of my main (DLG proc) procedere.Strange is that I need to fill NM_CLICK into wParam and not in lParam!?!So its working also if the code seems to be wrong above but problem here is that its just working after a second press on any key on keyboard so the problem seems to be the NM_CLICK so this I should send other anyhow but how is the question. greetz
LCF-AT Posted May 7, 2015 Author Posted May 7, 2015 Hi again, ok so now I found a other / better working solution.So it seems I need to alloc a local NMHDR struct and fill them. TESTA proc hWnd:HWND,uMsg:UINT,wParam:WPARAM,lParam:LPARAM LOCAL nmh:NMHDR ....... .elseif uMsg == WM_KEYDOWN .if wParam==25h || wParam==26h || wParam==27h || wParam==28h mov uMsg,0h ; zero WM_KEYDOWN in routine message mov nmh.NMHDR.hwndFrom, edi ; edi my LV Handle mov nmh.NMHDR.idFrom, WM_NOTIFY ; send custom message mov nmh.NMHDR.code, NM_CLICK ; send custom code notification invoke SendMessage,hWndStore,WM_NOTIFY,0,addr nmh ; hWndStore = Main routine Handle Ok maybe my code is not perfect or correctly for 100 % but it works. greetz
simple Posted May 8, 2015 Posted May 8, 2015 Look on msdn, you'll see that (for whatever reason) listviews that have a control as parent (like a listview inside a tab control) don't handle NM_CLICK & the solution is to subclass it to the parent. Few exceptions aside, don't think u should ever manually send messages like that, your main handler has no way of knowing whats a real click nor where the click ocurred.
LCF-AT Posted May 8, 2015 Author Posted May 8, 2015 Hi again, nothing special Ted,just try to lern or find out some basic ASM things where I got some problems etc. @ simple So I don't understand always everything from the MSDN docs and also some exsamples I can find on the internet are also not so easy.So lets check again what I did so far... My code does creates Tabs with a Listview (one tab one new LV) each time if I add a new tab.All new LVs I do let create with CreateWindowEx and right after creating the LV I got the handle of the new LV which I do use to call SetWindowLong API to subclass this LV so that it will access my new routine where I can catch WM_KEYDOWN & WM_CHAR.The reason why I wanna do this is that I want to check & control any keyboard press and to handle it by my own code and to prevent the system to handle it.My LV looks like this.... No. | Name | Link ------------------------------ 1 | Ted | ... <-- I have select this line now 2 | simple | ... 3 | else | ... 4 | bla | ... ------------------------------ Static: Ted <-- does show the name of selected line ------------------------------...so you see the LV has three rows (no/name/Link) and in the first I just set a number counter for each added line.Now if I code nothing about keydown & keychar then the system will take the control (default) of any key press and does check the key xy with row 1 (Numbers).If I have select the first line 1 and if I press key 2 or 3 or 4 then it will jump to the line who hold this value.All ok so far.So now I just wanted to change this so that the system doesn't use row 1 (No.) for this so it should use row 2 (Name) but it seems that I can't tell this the system and was the my first problem.I did check what for messages are used during a key press and found WM_KEYDOWN & WM_CHAR but to get them I had to subclass my LVs to catch these messages in my new extra routine which I just created for this.If I now catch WM_CHAR then I do execute my own code to check what key was pressed (maybe the e key) and then I do check each line for this letter in my row 2 (Name) just the first letter only and if from the selected line to next below or till top again (loop) was found this letter then I do select this new line and right after this I make the nmhdr changes with WM_NOTIFY & NM_CLICK and send them to my main routine which does handle these messages so that also all others as Static gets updated.After this it comes back to my extra routine after Sendmessage API where I then fill the uMSG routine message dword paramter WM_CHAR to zero to tell the system not to handle WM_CHAR before I do call CallWindowProc API.Also the same I do with WM_KEYDOWN up / down but here I just inc or dec the line etc. So I found not easier way to handle this.Maybe my way is not so correctly etc (not sure for 100 %) but it works and till now I got no trouble.So if you mean that this way is wrong or could make trouble anyhow later maybe etc then just show me how to do it right. I do just send the fake messages to my actually XY shown Listview only if something in the LV is selected and if not then not.Anyway,so if you know any better solution / example then you're welcome to show it. greetz
LCF-AT Posted May 9, 2015 Author Posted May 9, 2015 Hi again, short question: So I got almost everything working so far since I did started this topic but there is now one issue I need to handle about to find a tab control drag & drop solution.Only problem what I got about this is what kind of message check should I use so for tab control there isn't any BEGINDRAG message to find as for others so how to check this right now after the WM_NOTIFY message? Maybe anyone could post some little steplist what to use so that I can test it. Thank you
LCF-AT Posted May 10, 2015 Author Posted May 10, 2015 Hi, one question about TC_HITTESTINFO struct.So I tried to find out which tab I have clicked with left mouse button without to release the left button and found the message WM_LBUTTONDOWN which I could use but right afer this if I use SendMessage API with TCM_HITTEST then I always get -1 as return in eax but how? .elseif uMsg==WM_LBUTTONDOWN invoke GetCursorPos, addr tvhit invoke SendMessage,hwndTAB,TCM_HITTEST,NULL,addr tvhit As return in my TC_HITTESTINFO (flags) struct I get always value 1 which is TCHT_NOWHERE but why?So what I am doing wrong in that case? greetz
LCF-AT Posted May 12, 2015 Author Posted May 12, 2015 (edited) Hi again, still working on that tab problem.Is here nobody who can help a little?So it seem I can only check any is clicked tab at WM_NOTIFY but how to check a left mouse click at a tab (or anywhere) without to release the mouse click (still pressed down)?I also tried to use other ways as to ge the focus handle (working for LVs for exsample) but isn't working for tab control. Below I made a simple picture maybe it will help to get next time any answers. greetz EDIT: Ok so I see I have also to subclass the Tab control too!!!!Such a quark. So is there any kind of list or overview what the user have to subclass and what not etc? Edited May 12, 2015 by LCF-AT
LCF-AT Posted May 12, 2015 Author Posted May 12, 2015 Hi again, so is here no coder around who done this before and who could help with Tabcontrol drag & drop problems?So I can't use any other drag / drop method as for LVs or LTs etc so for TCs are not such messages present so what to do in that case?So is there any way or method to create a drag & drop code who can make the same as for LV column drag & drop or not?See the picture below.. ...so this I wanna also have with my Tabcontrol. Any infos would be welcome or if not then I think I need to ask on any other real coder forum. Thanks
REAP Posted May 12, 2015 Posted May 12, 2015 Hi, Unfortunately I don't have any hands on experience with this so I can't help you with your question, but I think you should consider using one of the development environments for your app rather than pure assembler. If you look at the majority of commercial applications that are available, they have not been written in assembler but rather in a higher level language (e.g. C++, MFC, Qt etc.); now as I don't have any experience with what you're trying to do I can't tell you which one is likely to be best for you - but there are people on the forums that no doubt can help. For instance @simple probably has some good ideas. My point is that the majority of app's are written using these development environments because they make it easier for the developer to create their app and while there is some overhead in terms of the size of the resulting code (versus pure assembler) in terms of what modern PC's can handle the size of the exe's is fine and clearly the performance is not a problem either. If you use one of these development environments you will also find it much easier to get assistance elsewhere if you can't find the answers that you need here. HTH
LCF-AT Posted May 13, 2015 Author Posted May 13, 2015 Hi, thanks for your answer but I also don't know about anything of development environments for assembler etc.So I try to handle all steps I wanna do manually and now I do stuck on the Tabcontrol drag & drop issue so the TC have no default messages for drag & drop as LV TV etc which I could use.I tried already to handle this problem manually on a little different way but I have now the problem that I can't create a transparent image (image or text of tab) so for this I should use some Image APIs which need a handle to the imagelist which I can't create for Tabcontrol (CREATEDRAGIMAGE). So on the other hand I found also some infos on internet in C+ but I can't understand the entire code maybe you?http://www.codeproject.com/Articles/2445/Drag-and-Drop-Tab-Controlhttp://www.suodenjoki.dk/us/productions/articles/dragdroptab.htm greetz
simple Posted May 13, 2015 Posted May 13, 2015 (edited) "if you've just spent nearly 30 hours, debugging some assembly, soon, you'll be glad to - write in C... ohhh write in C, write in C, yeah write in C..." >https://www.youtube.com/watch?v=H4YRPdRXKFs - please watch this video lcf, it can change ur life edit - my youtube video link wont show up - remove quotes - "https://www.youtube.com/watch?v=H4YRPdRXKFs" Edited May 13, 2015 by simple 1
Alzri2 Posted May 13, 2015 Posted May 13, 2015 LOOOOLI still believe that learning C is useless cuz there something better called C++. I see no significant advantage of C over C++,
mrexodia Posted May 13, 2015 Posted May 13, 2015 LOOOOL I still believe that learning C is useless cuz there something better called C++. I see no significant advantage of C over C++, There actually is an advantage a complexity difference of OVER 9000. Which you could see as an advantage if you come from C++.
REAP Posted May 13, 2015 Posted May 13, 2015 Hi, thanks for your answer but I also don't know about anything of development environments for assembler etc.So I try to handle all steps I wanna do manually I understand and if programming in assembler had worked out, it would have been the easiest path for you. The problem is that now that you're stuck you have found that most other programmers don't program in assembler, so your access to advice is limited. That's the problem. If you're going to keep working on app's I think you're going to be best off learning a development environment because the environment should make it easier for you to develop your app and when you do have questions, you will be able to find forums where you can get assistance (and that might not be here). Of course the downside is that you will need to learn the environment which will mean 'wasting' some time initially. So on the other hand I found also some infos on internet in C+ but I can't understand the entire code maybe you? http://www.codeproject.com/Articles/2445/Drag-and-Drop-Tab-Control http://www.suodenjoki.dk/us/productions/articles/dragdroptab.htmIf I could help you I would, I don't know C+ I'm afraid.
LCF-AT Posted May 14, 2015 Author Posted May 14, 2015 Hi, nice video simple. So you mean I should give "pea©e" a chance. Does it also mean that ASM is language which is limited and that I can't do or create some stuff what I have in my mind?Just a easy exsample,so I like the Tabs in my FF browser how they look and how they work if you move them etc so would you say that I could forget it when I wanna create almost the same tab stuff in any ASM code (not possible etc)? Of course I think its not so easy to switch now to a other language where I have again to start from zero and I am already happy to got a halfway good entry with ASM so that I can use it now more or less successfully to write any codes. Is C also for free and if yes with what version of C xy should I start or what do I need etc?!?Maybe I should give it a try next to ASM. @ REAP Yes I did search already a lot on the net about that problem and can't find any solution in ASM how to handle this situation.No idea what to do now.Trying to find any solution by testing other ways / APIs etc which could take much time.Sounds not so good that ASM seems to be limited or is a language without future.Also at the moment I have no clue about the other languages as C or C++ or how they all called. So I found this about the fav languages and C is on top. greetz
REAP Posted May 14, 2015 Posted May 14, 2015 Hi, I am certain that anything can be done in ASM (technically ASM is not limited) but ASM is not a "developer friendly" environment and as a result not to many people will use it (which means there won't be many people / forums around for you to ask questions when you get stuck). From the reading that I have done I think C or C++ will be your best bet. There have been plenty of discussions on whether C or C++ is "best" for a given task. At the end of the day I'm sure that either will be able to do what you want and both languages are widely used so either way you will be able to ask questions either here or elsewhere. The only other option you might want to consider is something like PureBasic (which isn't free) which Ted has been posting about on his blog but which might be easier to get started with. 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now