Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

APIEdit doesn't work

Posted on 2000-05-14
16
Medium Priority
?
288 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

Industry Leaders: 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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

705 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