Solved

APIEdit doesn't work

Posted on 2000-05-14
16
281 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses
Course of the Month6 days, 5 hours left to enroll

626 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