Solved

APIEdit doesn't work

Posted on 2000-05-14
16
270 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
 

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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

747 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now