Borland C++ Builder v6 - Missing Form

Hi everyone

I created a project with a single form in C++ Builder and added some source/header files. Everything resided in the same directory and worked fine. When I renamed and moved the form (.dfm file) and the matching source code (.cpp and .h) to a different directory, I was no longer able view the form in design mode.

The form is still there, the project compiles fine and the final executable works as expected too. I am stuck.

Thanks
Never used Borland C++ myself, but it probably just doesn't know the file is there. If you have something like a project view, import your renamed version into that.
I've added the files and that's why everything works fine. I just can't load the form in design mode.
That's funny. Is there some sort of error message or something the like?
There might be some compiler and/or the IDE generated files that should be deleted
There is no error message. It compiles fine and the resulting executable works fine too.

Also, I deleted all the object files and recompiled but the problem persists.
I mean, what happens when you open the form?
If I try to open the .dfm file through the IDE, the form opens in text mode. I can see all the delphi (?) code.

But when I press alt+F12 (or select the corresponding option), nothing happens.
It's been a while since I last used Delphi (the only Borland product I ever touched in my life), but I believe dfm files are not the actual form files, they are just textual representations of them.
The .dfm file contains delphi code which describes the actual form. The code for handling various events is stored in the corresponding .cpp file.

For example:
1
2
3
4
5
6
7
8
9
10
11
12
13
object FormMain: TFormMain
  Left = -4
  Top = -4
  BorderStyle = bsDialog
  Caption = 'Simple Kiosk P.O.S.'
  ClientHeight = 753
  ClientWidth = 1280
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11

// code continues 
That's what I mean. That's not the actual form file. That's just a human readible version that exists for... I don't know, I guess the GUI uses it for something. But it's not what the form is actually stored as.

That confused me back then too, but I did read that in the delphi manual.
Last edited on
The IDE uses that code to generate the form. In fact, if you modify this code...say change the client width and height, then these changes are reflected on the actual form. I know because I just did it.
Dammit, you are right.

I just checked it again though,
Caution should be used in altering this file as changes to it could prevent the IDE from being able to load the form.


I suppose the form has to have the same name as the project or some shenanigans.
I found a partial solution to the problem.

The original TFormMain.cpp had a line: #pragma resource "*.dfm"
I changed it to: #pragma resource "TFormMain.dfm"
Then I changed it back to: #pragma resource "*.dfm"

Now, the form does not appear instantly when I open the project, but only when I do the following:

1. Press Ctrl+F12
2. Select TFormMain (or the name you've given your form) from the list
3. Press F12 for the form to appear

I don't know exactly what happened but it works. Anyone know better, please lets us know.

PS: Thanks for the help hanst99 and coder777.
Last edited on
Topic archived. No new replies allowed.