• Welcome to Powerbasic Museum 2020-B.
 

News:

Forum in repository mode. No new members allowed.

Main Menu

CSED - Modification

Started by Gary Beene, October 17, 2013, 02:31:56 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Paul Squires

This works with FireFly Visual Designer and JellyFish Pro Editor as well. Press F6 while caret positioned over function name to take you to that function. Press Shift+F6 to return back.
Paul Squires
FireFly Visual Designer SQLitening Database System JellyFish Pro Editor
http://www.planetsquires.com

Gary Beene

Hey Paul!
Thanks for the suggestion ...
QuoteInstead of highlighting the text...
I'd though of that, but sometimes in my apps I have functions like MyTasks and MyTask, where the first calls the second repeatedly. So I wanted the option to highlight only the MyTask part of MyTasks.  Not exactly a strong case for highlighting, but it was the thought that drove my approach.

But, you bring up a perspective I wasn't thinking about - using the keyboard.   Not that I can't use the keyboard to highlight a sequence of strings, but I like the idea of your F6 - simpler to use 'cause there's no highlighting by keyboard required.

Gary Beene

Where is the code that changes the caption of the CSED main window, when a new file is opened?

I search for $CSEDVERSION, $CSEDCAPTION, and even the [ symbol. 

I found AfxSetWIndowText used on the TABs, but not on the main window caption.

Nor do I see it in the CSED_OpenFile procedure.

I even made a temp file containing every include/bas file in CSED, searching that way instead of guessing which include might have contained the right code.

Would someone point me in the right direction?  And please, don't let it be really obvious!  :)

José Roca

#18
Be patient. You're new to MDI. The caption that is changed is not the caption of the main window, but the caption of the MDI window. You must be running the editor with the option to maximize MDI child windows activated and you're only seeing the tabs. See the capture below and you will see that the caption of the main window only has CSED and the version number and that each MDI window has as the caption the path of the loaded file.

The captions of the MDI child windows are changed in a couple of places: one in the CSED_OpenFile function of CSED_FILE.INC. This function first checks if the file is already loaded by enumerating the MDI child windows; if it is not, it calls the CSED_CreateMdiChild function, that creates a new MDI child window using the path of the file as the caption. Another place is in the CSED_SaveFile funcion, where it uses IF hMdi THEN AfxSetWindowText hMdi, strPath.

Gary Beene

Thanks Jose,
QuoteYou're new to MDI.
Yes, and I'm glad the text assignment was as you described rather than some trivial thing, such as having overlooked a few lines of code.

As you surmised, I did have the child windows maximized.

José Roca

The menu has an item called "Window" with several MDI related options, such cascade, tile horizontal, tile vertical and Arrange icons, because MDI windows can be cascaded, tiled or iconized. besides maximized. It also keeps a list of the files loaded.

The tab control is foreign to MDI and only is being used by convenience. But selecting a tab does nothing else that highlight that tab, because it has not child controls,  and send you a message indicating that the user has changed the selection.


José Roca

If windows are cascaded or tiled, you can select them by clicking in any part of them, e.g. the caption. See a capture with the windows cascaded.

Paul Squires

I believe the general trend is away from true MDI applications. The introduction of TAB controls to faciliate the switching amongst child windows makes it very easy to deal with multiple document layouts. In my personal experience, I have not had a burning need to create a true MDI application for over 10 years. I find that SDI applications and TAB'd child forms are much easier to implement and maintain. Of course, there will always be those situations where MDI is better (and I would argue only marginally), but for the vast majority of time you can get by without it.
Paul Squires
FireFly Visual Designer SQLitening Database System JellyFish Pro Editor
http://www.planetsquires.com

Gary Beene

Jose,
A trivial question on a couple of lines of code I saw in CSED ...

Why did you do this (create an extra variable) ...
   Local hwndClient As Dword
   hwndClient = pWindow.CreateMDIWindow(101, 0, 0, 0, 0, -1, -1, hWindowMenu, CodePtr(CSED_MDIWindowProc))
   pSed.hwndClient = hwndClient


Instead of this:
   pSed.hwndClient = pWindow.CreateMDIWindow(101, 0, 0, 0, 0, -1, -1, hWindowMenu, CodePtr(CSED_MDIWindowProc))

José Roca

#24
It's hard to remember. As I said, one of the main purposes for which I wrote this editor was to test the beta versions of the compiler, and my headers and clases, with non trivial code. Of course, the beta versions of the compiler had bugs that this application helped me to discover. Probably, when I wrote these lines, there was a bug that didn't allowed to do the assignment directly, and later I forgot to change it. As you can see, the code uses many of the new features of PB 10, such classes, unicode, collections, linked lists... Many times I had to use workarounds until the bug was fixed.

José Roca

I also used #IF DEFs to test that it worked either using ANSI or UNICODE. Currently, all my applications are unicode only.

Gary Beene

#26
Jose,
When I run this short code, taken from your CSED source code files, my modified version of CSED starts alternately highlighting the TAB that is active when the code begins and the last TAB on the right. The program never leaves the loop, freezes up and I have to close the program to stop the flickering.

It seems to be identical to code you've used several times in CSED, but I'm getting unexpected result.

   hMDI = GetWindow(pSed.hwndClient, %GW_Child)
   While hMDI
      vPath = AfxGetWindowText(hMdi)                        'get path from the collection
      nTab = CSED_GetTabNumberFromPath(Variant$$(vPath))    'get TAB number from Path
      TabCtrl_SetCurSel(pSed.hTabMdi, nTab)                 'select the TAB
      MDIActivate(pSed.hwndClient, hMdi)                    'activate this MDI child window
      hMDI = GetWindow(hMDI, %GW_HWNDNEXT)
   Wend

Am I doing something obviously wrong?

Gary Beene

#27
Debugging .... I find that if I test the nTab value each loop, it alternates between 0 and 2 (when I have 3 files opened).  Don't know why it's skipping the nTAB=1 value.

The hMDI value likewise alternates between 2 values, not three.

José Roca

#28
I don't understand which is the puporse of that code. After vPath = AfxGetWindowText(hMdi) one should check if it is the window wanted, activate it and leave the loop, e.g.:


hMDI = GetWindow(pSed.hwndClient, %GW_Child)
While hMDI
   vPath = AfxGetWindowText(hMdi)                        'get path from the collection
   IF VARIANT$$(vPath) = "<something>" THEN
      nTab = CSED_GetTabNumberFromPath(Variant$$(vPath))    'get TAB number from Path
      TabCtrl_SetCurSel(pSed.hTabMdi, nTab)                 'select the TAB
      MDIActivate(pSed.hwndClient, hMdi)                    'activate this MDI child window
      EXIT DO
   END IF
   hMDI = GetWindow(hMDI, %GW_HWNDNEXT)
Wend


Gary Beene

#29
Hi Jose, and thanks for responding!

I posted the full function back up in post #9.  That code contains an exit strategy, as you suggest, which is to exit when the scintilla control associated with the TAB has a procedure of a given name.  That code seemed to be working, but is now showing the problem I described.

I pared the post #9 code down to just the few lines above, just to show which code is giving the problem.

The loop, without an exit function strategy, should end on its own. It should walk sequentially through tab numbers 0-2 (when I have 3 files open in CSED). But it does not. It walks repeatedly between tabs 0 and 2 - and I don't see why it is doing that.