Jump to content

I want to make a Notepad alternative in C


Recommended Posts


Well, you can try to add 4 as flag.

Another approach: When it's a real 32 bits program, I suppose it's targetting NT3.51 (or maybe Win32s), but in any case windows 3.x. You can change the PE header to let it target window 4.0 (win95). The executable is the same, but windows will treat it different. The preferred way to change the header is to let the linker do it. For Borland 5.5 (which is free, by the way) you add -V4.0 to the linker command line. I don't know if this will work for 4.5 too.

The other way is editing the executable. You can use Stud_PE for that. Download it here, load your executable in it, click on 'Basic headers tree view in hexeditor' button, open 'Optional header', and edit Major- and MinorSubSystemVersion. (Beware, it's little-endian, so the major must be 0400, and the minor 0000.)

Link to comment
Share on other sites

I edited the EXE, and now the Search dialog won't open anymore. In any case, major version was 0300 and the minor was 0A00. Bad Borland C++. :(

I'd like to get Visual Studio 6 on my PC, but I'm not sure if I can install it without IE. I've already read how to prevent the Java update, in any case.

Link to comment
Share on other sites

Too bad. MS changed the dialog templates somewhere in the transition Win 3.x-4.x. Apperently you've got old-style resources in your project, and Windows seems not to accept that from a program targetting W4.0. Maybe your resource compiler (brcc32.exe?) can create newstyle resources. I've got two versions of Borland, 5.0 and 5.5. Both can create old and new style, but 5.0 defaults for old style, and 5.5 for new style.

The resource compilerflags are -16 and -32.

I really don't know if VS6 will install without IE. The interactive help will not work, because it relies on IE html engine. What about Vision Windows for BC++5.5?

Edited by Mijzelf
Link to comment
Share on other sites

Got Borland C++ Compiler 5.5 after jumping through registration hoops. And then I found out that Visual Windows has a version with it included. Oops.

Installed Visual Windows, and on start-up it complains about missing KERNEL32.DLL:GetLongPathNameW in a MSVC 8.0 DLL. So the website lies!

Edited by BenoitRen
Link to comment
Share on other sites

I managed to compile my resource and my program with the command line tools. But now no dialog works! Not my own, nor an open or save as dialog.

I've tried leaving out the resource. Doesn't make any difference.

What's also weird is that the size of the exe output by the compiler is 50 kB, versus the 29 kB one output by Borland C++ 4.52.

The problems keep piling up. I now added the path to the bin directory to the path environment variable, and whenever I try to compile now I get "Response file not allowed here.". Google doesn't have anything to say about that.

Edited by BenoitRen
Link to comment
Share on other sites

The examples of theForger don't show open/save dialogs either. I ran Dependency Walker on one of them, and it looks for Borland32 in KERNEL32.DLL. It's the same thing with my compiled program. This is weird.

Link to comment
Share on other sites

I put some MessageBox calls in WM_COMMAND to figure out if these things were even getting called. Turns out they do.

As for the size, Borland C++ 4.52 uses the Borland C++ runtime to achieve a smaller size. I noticed this by using Dependency Walker.

The open and save dialogs work now! I looked at the page of theForger's tutorial that dealed with them, and it looks like I needed to use OPENFILENAME_SIZE_VERSION_400 instead of sizeof(ofn) when specifying the size of the OPENFILENAME struct. Whew!

My search dialog still isn't working, though. What's more, it only works in my program compiled with Borland C++ 4.52 when the IDE is running! Crazy stuff.

Link to comment
Share on other sites

All right! I got my search dialog to work! Here's what I did. I changed the CONTROLs that were defined as checkboxes to CHECKBOX, and the CONTROLs defined as radio buttons to RADIOBUTTON.

I forgot to change DIALOG to DIALOGEX, it seems, but it worked either way. Yay!

Link to comment
Share on other sites

Glad you sorted it. Welcome in the wunderful world of real Win4.0 targeting programmers. :yes:

/Edit: You're right about Visual Windows. The site doesn't claim W95 as beeing supported, but it says VW is developed using VC6, in which case msvcr80.dl

l wouldn't be used. You can try to use an hexeditor (or maybe Stud_PE) to edit msvcr80.dll. Change GetLongPathNameW in GetFileType. When you're lucky GetLongPathName is never called, and when it is, GetFileType will return 0, (FILE_TYPE_

UNKNOWN) which is interpreted as 'No long path name available for this particular file'. (I hope)

Edited by Mijzelf
Link to comment
Share on other sites

I'd rather not have MSVC8 DLLs at all on my machine. I'll get by without an IDE for now.

I implemented "Go To Line" and "Save"! Save was a bit tricky, since it involved a string, which always needs special treatment. I used a global string to keep the file name of the opened file, and I NULL the first char when I do "New". Seems to work well! I would have preferred to avoid using the string library, though.

Anyway, my notepad alternative is now good enough for basic editing, so I'll be using it to edit the program's own source code. How cool is that! :)

Next, Search and Replace!

Link to comment
Share on other sites

I've been too lazy to do Search and Replace, so I've been doing other little things, like focusing the RichEdit, making it remember the file filter, and adding keyboard shortcuts.

Now I want to add a context menu. However, it's not working. I never receive a WM_CONTEXTMENU message when I right-click in the RichEdit. I've got all the rest figured out: call TrackPopupMenu with the menu handle using the parameters of the WM_CONTEXTMENU message.

Any ideas?

Link to comment
Share on other sites

Does your editor have IME support? Or is it not that type of editor?

I remember when I tried creating a control with IME support. I went to hell and back twice, but managed to get a working code snippet in the end.

Edited by SlugFiller
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...