?
Solved

APIEdit doesn't work

Posted on 2000-05-14
16
Medium Priority
?
293 Views
Last Modified: 2010-04-04
The followinf sourcecode creates a window and some controls. One of them, the editcontrol doesn't work. It seems to be read-only, but I havn't set this flag. Why can't the user insrt text in the editcontrol???

type tc_item = record
mask,lpReserved1,lpReserved2:UINT;
pszText:LPSTR;
ccTextMax,iImage,lParam:integer;
end;

const
TCM_INSERTITEM = $1307;
TCIF_TEXT=1;
var handles:array[1..9]of integer;
    comctrls:integer;

procedure init;
var t:tc_item;
begin
handles[1]:=CreateWindow(pchar('test'),pchar('Window'), WS_caption  or ws_sysmenu or ws_minimizebox,cw_usedefault, 0, 260, 334, 0, 0, hInstance, nil);
//'test' is a registered windowclass
comctrls:=loadlibrary(pchar('c:\windows\system\comctl32.dll'));
handles[2]:=Createwindow(pchar('SysTabControl32'),nil,ws_child or ws_visible,0,0,254,270,handles[1],0,hinstance,nil);
t.pszText := Pchar('Tab1');
t.ccTextMax := 13;
t.iImage := -1;
t.mask := 1;
sendmessage(handles[2],tcm_insertitem,1,integer(@t));
handles[5]:=CreateWindow(pchar('button'),pchar('Group1'),ws_child or ws_visible or bs_groupbox,
5,31,233,143,handles[2],0,hInstance,nil);
handles[9]:=CreateWindowEx(ws_ex_clientedge,pchar('Edit'),nil,ws_child or ws_visible,
10,39,185,21,handles[5],0,hInstance,nil);         {This edit doesn't work}
showwindow(handles[1],sw_normal);
updatewindow(handles[1]);
end;
0
Comment
Question by:LuK
  • 10
  • 5
16 Comments
 
LVL 1

Expert Comment

by:sistudio041900
ID: 2808650
how is hInstance initialized and who is the calling application? I have found that Edit control when placed on Delphi form thats get activated from non-Delphi application (using the "CreateParented") function will behave as it is 'read only' ie no-editing this is very similar to the behaviour you describe. Is the host VCL application that includes forms.pas ?
0
 
LVL 3

Expert Comment

by:bryan7
ID: 2809069
listenning
0
 

Author Comment

by:LuK
ID: 2810994
Edited text of question.
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 

Author Comment

by:LuK
ID: 2811003
Edited text of question.
0
 

Author Comment

by:LuK
ID: 2811020
Adjusted points from 85 to 95
0
 

Author Comment

by:LuK
ID: 2811021
To Sistudio:
hInstance is a global variable, witch is defined in system.pas, and witch is automatically initialized(Sorry about my english).
The host application is written in Delphi, and the posted procedure is directly in the projectfile.

0
 
LVL 1

Expert Comment

by:sistudio041900
ID: 2813377
the procedure is in the Project file? you mean the .dpr file? where and when is class 'test' registered? before calling 'init' did you create any visbible forms in the delphi project? as of trouble shooting one good thing is microsoft spy, you can see all windows messages sent to any window, sometimes it shows to many mess but its possible to customize. you should check if your EDIT windows receives focus, etc... BTW what are you actually doing? the way of programming is kinda 'hardway around' in delphi world. your kind of of programming was used with Turbo Pascal for Windows. I think there the problem is within the 'test' windows class, ie the window procedure there.
0
 

Author Comment

by:LuK
ID: 2813970
Adjusted points from 95 to 100
0
 

Author Comment

by:LuK
ID: 2813971
Yes, I mean the .dpr file and there are no other visible components crated before calling 'init'. I try to make an applicastion without including the unit 'Forms', because it is very big.
The class 'test' is registered as follows:
procedure registers;
var w:Twndclassex;
begin
w.style := cs_vredraw or cs_hredraw;
w.lpfnWndProc:=@WndProc;
w.cbClsExtra :=0;
w.cbWndExtra:= 0;
w.hInstance:=hinstance;
w.hIcon:=0;
w.hbrBackground :=color_window;
w.lpszMenuName:=nil;
w.lpszClassName := pchar('test');
w.hCursor := loadcursor(0,idc_arrow);
w.hIconSm :=0;
w.cbSize := sizeof(w);
registerclassex(w);
end;

And the Window procedure is at the moment only as follows:
function WndProc(hWnd,Msg,wParam,lParam):longint; stdcall;
begin
result:=0;
if Msg = WM_DESTROY then postquitmessage(1)
else
result := defwindowproc(hwnd,msg,wparam,lparam);
end;
end;
0
 
LVL 1

Expert Comment

by:sistudio041900
ID: 2816052
well I did think that this is the case. well the bad thing is that you 'have' to include 'forms' or someother unit... or you have todo a bit more in your window procedure. It isnt so easy to 'opt' out from using 'forms' :( now your options there is something called extrame class library orsomething else its a real minimal class libary for Delphi that doesnt use VCL at all! you may use Turbo Pascal for Windows coding style to create really small apps, take a look at
http://case2000.isp.ee/files/ELMICRO.ZIP
its a complete windows applications with full source code exe file size is 40kb (| the author was amazed myself) there are lotsa TPW sources that actually can be compiled under Delphi (ie you without VCL)
0
 

Author Comment

by:LuK
ID: 2817936
I include "someother" units(windows and messages). Why should I include the "forms" unit? Or is the editing of the editfield only implemented in this unit?
thanks for your sample programm, I will try it.
0
 
LVL 1

Expert Comment

by:sistudio041900
ID: 2820130
because TApplication is in Forms unit! Windows message loop is not functionaning, and those the misbehaviour with your controls. If you look at various types of Delphi application you see that either Forms or some other unit that contains TApplication is always used for GUI applications. So you cant avoid to use Forms so simply. If you want to make a small gui application then you must either use 'old style' see my demo, or create your own minimal replacement for forms unit.
0
 

Author Comment

by:LuK
ID: 2821293
Sorry, but I havn't Turbo Pascal, and in Delphi, your sample doesn't work.

I use in my programm a C-similar messageloop:
var Tmsg;
....
while getmessage(msg,0,0,0) do
dispatchmessage(msg);

Isn't that enough?
Or have I to add the "TranslateMessage"-call? Or have I to implement the the editfield-behaviour?
0
 
LVL 1

Accepted Solution

by:
sistudio041900 earned 360 total points
ID: 2821311
you have todo something thats done in forms unit, but I cant say what exactly
0
 

Author Comment

by:LuK
ID: 2827132
Adjusted points from 100 to 120
0
 

Author Comment

by:LuK
ID: 2827166
Now I have found It out by myself, I only have to use "TranslateMessage".
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Through the video, you can check the migration process of Outlook PST file to PDF. Kernel for Outlook to PDF tool can convert Outlook emails with all attributes like Subject, To, From, Cc, Bcc and other folders such as Inbox, Outbox, Sent Items, Jun…

585 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question