Solved

APIEdit doesn't work

Posted on 2000-05-14
16
273 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

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 120 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Printing problem 2 91
Convert GUI app into console app for Win32 Env 5 98
Need Help Delphi 2010 CheckBox1 Stored value in memo 13 66
RESTRequest Parameter 4 30
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

786 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