Newsgroup: it.comp.programmare.win32
Titolo: [C++ builder] Avviare programma da un file

Salve,
supponiamo di creare un programma di prova con 2 Edit una per il campo nome 
e una per il campo cognome.
Ora immaginiamo di poter salvare su file .rb questi due dati (in maniera 
molto semplice anche facendo una semplice copia dei valori dalle edit al 
file) e di aver implementato una funzione per caricare i dati di questi file 
.rb. E' possibile fare in modo che al click del file .rb si apra 
automaticamente il programma e che carichi il contenuto del file? Un po' 
come avviene in moltissime applicazioni.
Grazie 

come avviene in moltissime applicazioni.
Se l'estensione del file e' correttamente registrata nel S.O. basta
usare ShellExecute() .

 usare ShellExecute() .
Mi fai un'esempio?
per caso non c'e' il main in C++ Builder? Volevo usare char* argv[].
Mi pare ci sia un WinMain ma non so in che file sia e non so se faccia
quello che mi serve.
Grazie

 quello che mi serve.
Si trova nel file con il nome del progetto ed estensione CPP.
-- 
Stefano Frosio
www.esse-effe.com

 Si trova nel file con il nome del progetto ed estensione CPP.
Ah ecco se lo apro direttamente da C++ Builder non me lo visualizza mentre 
con un'editor qualsiasi si... 

 visualizza mentre con un'editor qualsiasi si...
A me lo visualizza. E lo ha sempre fatto, da BCB3 in avanti.
-- 
Stefano Frosio
www.esse-effe.com

 A me lo visualizza. E lo ha sempre fatto, da BCB3 in avanti.
Bo a me invece visualizza la Unit1.cpp anche se apro Project1.cpp, non 
saprei.
Comunque, ho un problema più importante:
Ho 2 form (Form1 e Form2)
Nella Form2 ho un Button e un OpenDialog (che ho chiamato open). Nell'evento 
onClick del Button c'e' questa riga di codice:
open->FileName = "Ciao.txt"
Nell'evento OnCreate del Form1 metto la seguente istruzione:
Form2->Button1Click(Sender) ma mi da errore di esecuzione... stessa cosa se 
tento di fare Form2->Show() mentre con qualsiasi altra istruzione 
all'interno del Button1Click come un semplice assegnamento tipo:
Caption = "Prova"
Non da alcun errore...
Come mai? 

 qualsiasi altra istruzione
Probabilmente quando viene eseguito Form1::OnCreate (o il 
costruttore) Form2 non è ancora stato allocato. Hai verificato 
quanto vale quel puntatore?
-- 
Stefano Frosio
www.esse-effe.com

 Non utilizzare mai OnCreate. Utilizza il costruttore del form.
Se intendi:
__fastcall TForm1::TForm1(TComponent* Owner)
    : TForm(Owner)
{
    Form2->Show();
}
Mi da errore lo stesso perché Form2 è ancora nullo.
Ciao 

 Mi da errore lo stesso perché Form2 è ancora nullo.
No, non intendevo quello, infatti ho precisato che nel 
costruttore avresti avuto, giustamente, lo stesso problema. 
Utilizzare il costruttore anzichè OnCreate è un consiglio 
generico che peraltro ti avevo già dato.
-- 
Stefano Frosio
www.esse-effe.com

 OnCreate è un consiglio generico che peraltro ti avevo già dato.
Si ma infatti ho provato e non funziona, come posso ovviare?
A meno che il costruttore che intendi tu non sia un'altro.
Ciao 

 A meno che il costruttore che intendi tu non sia un'altro.
Scusa, ma cosa hai provato? Riguarda il mio messaggio, sono due 
consigli separati.
Per quello che posso intuire Form1 viene creato prima di Form2 
quindi nel costruttore di Form1 non puoi utilizzare Form2, 
semplice.
-- 
Stefano Frosio
www.esse-effe.com

 costruttore di Form1 non puoi utilizzare Form2, semplice.
Si infatti chiedevo una soluzione a tale problema...
Ciao 

 Non utilizzare mai OnCreate. Utilizza il costruttore del form.
In un programma che sto facendo l'ho usato varie volte... che problemi 
potrei avere che invece non sorgerebbero se spostassi il codice da OnCreate 
al costruttore del form?
Ciao 

 il codice da OnCreate al costruttore del form?
Riguardati questo thread e i link contenuti: 
http://groups.google.it/group/it.comp.programmare.win32/browse_thread/thread/43d4e8420c97a649/d39c8d7fee5f8304
-- 
Stefano Frosio
www.esse-effe.com

 Si infatti chiedevo una soluzione a tale problema...
Scusa eh, a grandi linee stai facendo:
1) creo (instanzio) oggetto A
2) chiamo un metodo dell'oggetto B
3) creo oggetto B
Ovvio che il passaggio 2 dà errore. Quindi crea l'oggetto B (in 
questo caso Form2) prima di richiamare un suo metodo. Come farlo 
nel tuo codice lo puoi sapere solo tu.
-- 
Stefano Frosio
www.esse-effe.com

 Riguardati questo thread e i link contenuti:
http://groups.google.it/group/it.comp.programmare.win32/browse_thread.
..
Ah si accenna anche al costruttore... io ricordavo che la discussione
era piu che altro incentrata sull'uso di OnCreate  di OnActivate.

On 4 Gen, 15:56, "Stefano Frosio"

Si certo ma pensavo ci fosse un modo standard che provvedesse a creare
automaticamente gli oggetti necessari.
Ciao

 Sì, c'è. Ma ti conviene utilizzare la comoda ParamStr().
In quale file si trova il main?

> In quale file si trova il main?
Ti ho già risposto nel mio primo reply: WinMain si trova nel 
file con il nome del progetto ed estensione CPP (che se non ho 
capito male nel tuo caso è Project1.CPP).
-- 
Stefano Frosio
www.esse-effe.com

 caso è Project1.CPP).
Ah quindi con Main intendevi il WinMain.
Ciao 

also
    for assault." The Attorney General continued to raise objections,
    when the Chief Justice said: "I have said as much as I choose to
    say, and I will not be put to question by the Attorney General. If
    you have any difficulty, come to the Court in Chambers."
Governor Hennessy, in reporting the incident to the Secretary of State
at London, adds: "I sent a note to the Attorney General, saying I
thought that the prosecution suggested by the Chief Justice should
take place; but it was found that the accused parties were not in the
Colony." After this manner many cases brought to the attention of the
officers of the law by parents or guardians of children of kidnaping
and trading in girls and children failed to secure the attention they
deserved. It seems to us not at all amazing, when one reads this past
history, that by the time Chinese girls have seen and learned all that
they must in the Colony of Hong Kong, when brought to this country
they are utterly incredulous as to the g

get him into a hospital and have him nursed and
    cured; but I would not put a ladder up against my window at night
    and leave the windows open in order that he might steal my goods
    without danger of breaking his neck.
    "You will see clearly, also, the cowardliness and unmanliness of
    this law, inasmuch as it sacrifices women to men, the weak to the
    strong; that it deprives the woman of all that she has in life, of
    liberty, character, law, even of life itself (for it is a process
    of slow murder to which she is subjected), for the supposed
    benefit of men who are mean enough to avail themselves of this
    provision of lust.
    "Besides being grossly unjust, as between men and women, this law
    is a piece of class legislation of an extreme kind. The position
    and wealth of men of the upper classes place the women belonging
    to them above any chance of being accused of prostitution. Ladies
    who ride in carriages through the street at night are in no danger
    of being molested. But what about working women? what about the
    daughters, sisters and wives of working men, out, it may be, on
    an errand of mercy at night? and what, most of all, of that girl
    whose father, mother, friends are dead or far away, who is
    struggling hard, in a hard world, to live uprightly and justly
    by the work of her own hands,--is she in no danger of this law?
    Lonely and friendless, and poor, is she in no danger of a false
    accusation from malice or from error? especially since under this
    law _homeless_ girls are particularly marked out as just subjects
    for its operation; and if she is accused, what has she to rely on,
    under God, except that of which this law deprives her, the appeal
    to be tried 'by God and my country,' by which it is understood
    that she claims the judicial means of defense to which the law of
    the land entitles her?
    "I will only add that this law has a fatally cor

hands, with their feet
thrown up into the air, or spinning along on all fours like wheels,
or going through various other antics. And, contrary to anything that
could have happened away from the open ports of China, there were many
women in the parade, and girls too. They were on horseback, in sedan
chairs, borne on wheeled platforms, like our "Goddess of Liberty"
representations on the Fourth of July; walking, and sometimes riding
on bullocks. We counted 150 women in all. These were dressed and
painted up in such a style that a single glance showed they belonged
to the disreputable class, and their old "pocket-mothers," were to
be seen walking along close to them and keeping a sharp lookout over
their gaudily dressed slaves. Yet more painful was the sight of
the little girls, bound to heavy wires and placed in all manner of
contortions. Here was a girl about sixteen, standing cross-legged on a
moving platform, holding a spear in each hand, the spears crossed in
front of her breast, and a little girl dangling from each spear-point.
So it appeared, but in fact all were well wired into the distressing
shape they occupied, and it was said that none of them could have
endured the position for a moment but for plentiful doses of opium.
Next passed a girl standing on the moving platform, holding a spear at
arm's length, and a three-year-old girl standing on its point. Then a
little boy holding a long rod from which was suspended a tiny child. A
girl passed sitting on a stool and holding a sword by its point with
a child of four suspended from its handle, and next a girl holding a
sword by its handle, and the child suspended from its point. One
girl sat playing a flute held up high in the air, and a girl of six
appeared to be suspended from it. One poor little thing was borne high
up in the air, astride a turning-pole, with legs well crossed beneath
the pole. And the

they
got a reward in money besides. So this cook is ordered off by his
master to "catch some unlicensed prostitutes," with the same _sang
froid_ as though ordered to go catch some fish for dinner. The cook
seemed to know where to get the most ardent assistance for the task
his employer had set him, for he says: "I got the assistance of a man
who is master of a licensed brothel in Wanchai." To be sure; who would
be so interested in capturing women and getting them condemned to go
and live in a house licensed by the Government as the man in the town
at the head of the licensed house? The cook was given a dollar as
bait, with which to catch the woman. Inspector Lee, who followed up
the men to make sure of the capture, found the dollar given by King
to his cook "lying on the bed" in the room occupied by the women,
and they were convicted on no other evidence than this and Lee's
"suspicions."
Private Michael Smith of the 80th Regiment was given four dollars by
Inspector Morton and instructed to go to a certain Mrs. Wright at
her quarters, and try to debauch her; he drank brandy with her [at
Government expense?] from 10 p.m. until 5 a.m., but failed in his
errand. Why did she not turn him out of the house? Women were
frequently fined for daring to resent the aggressions of these
informers. In one case a man was struck for trying to obstruct the
arrest of a girl of 14, and 

forward toward her with a cry of pity.
Great tears were rolling down her cheeks, and she seemed to look
straight into our eyes, and attempted a sickly smile at our
expressions of pity.
Later, after the procession of fishes, we sat in company with two
Chinese ministers of the Gospel who came to call upon us, and
discussed in sadness the scenes of the day. They said, if we had
understood the native language and joined in the procession, as they
did at times, we would have heard the old "pocket-mothers" and other
owners of these girls driving bargains for their sale, temporarily
or permanently, with the men of the crowds. These native Christians
marvelled that Englishmen and American men who called themselves
"Christians" could have joined in these festivities in honor of a
heathen temple, and that the Governor should have made a speech of
congratulation, with no rebuke of these scenes of inhuman torture of
women and child slaves, when the procession paused at his door. These
parades continued two or three days, always accompanied by the great
paper dragons, whether in the daytime or at night, by the noise of
deafening tom-toms, and the sickening sight of tortured slave-girls.
CHAPTER 15.
"PROTECTION" AT SINGAPORE.
"Ladies, I wish to introduce to you Mr. ---- He is eager to meet you,
and I am sure you will be glad to meet him. You are working along much
the same lines. Mr. ---- I assure you, is, in fact, interested in
every good thing that is done in this City, and in every good thing
that comes this way. We all count on his sympathies. I am glad to have
the priv

affection, discharge this duty
    to the best of my ability."
CHAPTER 10.
NOT FALLEN--BUT ENSLAVED.
The Report of the Commission affords the following instructive
account of the difference in the moral and social status between the
prostitute of the East and West:
    "In approaching the subject of prostitution, as it is found in
    Hong Kong at the present day, it is absolutely necessary for a
    full and just comprehension of it, to keep in mind two distinct
    considerations. One is the almost total identity of the whole
    system of prostitution, which since times immemorial is an
    established institution all over the large empire of China. The
    other point to be kept in mind is the radical difference
    which distinguishes the personal character, the life and the
    surroundings of Chinese prostitutes from all that is
    characteristic of the prostitutes of Europe." ... "At the present
    day the Chinese prostitutes of Hong Kong have but very little to
    distinguish them, either in the past, present, or future of their
    personal lives, or in their position and surroundings, from
    the prostitutes of the 18 provinces of China.... Those of the
    prostitutes of Hong Kong who are inmates of brothels licensed for
    foreigners only, or who live in sly broth

them. This was "protection" from the
official standpoint.
Mr. Labouchere had replied with his approval of this Ordinance dealing
with contagious diseases due to vice, as though the application for
the measure had been made in behalf of the slaves of Hong Kong. Such
was not the case. The enclosures in Sir John Bowring's despatch had
been a sensational description of the urgent need of vicious men for
the active protection of the Government from the consequences of
their vices. Later, a Commission of Inquiry into the working of this
Ordinance comments upon official statements as to the satisfactory
consequences of the enactment of the measure in the checking of
disease. The Commission demonstrates that in many instances their
statements were absolute falsehoods, as proved by statements made by
the same officials elsewhere. Since these officials are proved to have
been so untruthful after the passing of the Ordinance, we can put no
reliance on their statements previous to its enactments, and the
more so because the statistics for Hong Kong in its early days are
hopelessly confused with the general statistics for all China,
wherever British soldiers or sailors were to be found. Therefore they
are unavailable for citation. But as to statements made after the
passage of the Ordinance, we append a compilation, as set forth by Dr.
Birkbeck Nevins of Liverpool, England.
    SHAMELESS AND YET OFFICIALLY-SANCTIONED FALSEHOOD IN PUBLISHING
    OFFICIALLY UTTERLY UNTRUE STATISTICS IN FAVOUR OF THE C.D. ACTS IN
    THE BRITISH COLONY OF HONG KONG WITH THE SANCTION AND AUTHORITY OF
    THE COLONIAL GO

the Singapore labour trade will be understood when it is known
    that the number of Chinese who came to this port last year, either
    as genuine immigrants or for transshipment to other ports, was
    122,029, which is actually more than the entire Chinese population
    of the town. In connection with the immigration of this multitude
    of men and women, speaking many dialects of a language which is
    wholly unknown to the officials of the British Government in the
    Straits, with the exception of perhaps half a dozen persons, it
    cannot be wondered at that many abuses arise, and the suspicion
    has gained ground and is frequently given expression to, in the
    public press and elsewhere, that many of the immigrants do not
    come to Singapore of their free will. Moreover, it cannot be
    denied that the circumstances under which the Chinese come to
    Singapore and are forwarded to their destination lend colour to
    this suspicion, so that it may fairly be inquired whether the
    efforts made by the Government of the Straits Settlements to
    control the Chinese coolie traffic and to prevent a secret form
    of slavery have been attended with any success, or are at all
    adequate to the requirements of the case.
    The Annual Report for the year 1892 on the Chinese Protectorate in
    the Straits Settlements which is the department charged with the
    control of immigration, was published on the 5th of May, 1893, and
    states that of the 122,029 Chinese deck passengers who arrived in
    Singapore from China during the year, 111,164 were males, 6,867
    women and 3,998 children. The circumstances under which the men
    and the women are brought to Singapore are in many respects the
    same, but inasmuch as a large number of the women and some of
    the children are imported for immoral purposes, this part of the

late
any special _modus operandi_ observed in the proceedings of kidnapers
differing from what had been observed and known formerly?" To this
the Chinese gentlemen present replied that "there was indeed a marked
difference observable in the proceedings of kidnapers of late, because
they had become acquainted with the loopholes British law leaves open,
also with the principle of personal freedom jealously guarded by
British law, and that through this knowledge their proceedings had
not only become less tangible for the police to deal with, but
the kidnapers had been emboldened to give themselves a definite
organization, following a regular system adapted to the peculiarities
of British and Chinese law, and using regular resorts and depots in
the suburbs of Hong Kong." In support of this, Mr. Fung Ming-shan laid
on the table two documents written in Chinese. One of these contained
a list of 38 different houses in the neighborhood of Sai-ying-pim and
Tai-ping-shan used by professional kidnapers, whose names are given,
but whose residence could not be ascertained. The other document
consists of a list of 41 professional kidnapers whose personalia have
been satisfactorily ascertained.
The foreign Magistrates present then pointed out to the Chinese
members of the meeting that one great difficulty the Government
frequently met in dealing with such cases was the question, what

the introduction into our social fabric of their slaves,
and Christian womanhood will fall before it. "Ye have not proclaimed
liberty every one to his fellow, therefore I proclaim liberty to you,
saith the Lord, to the sword, and the famine, and the pestilence."
Having yielded before counsels of despair, those who should have stood
shoulder to shoulder with statesmen like Sir John Pope Hennessy and
Sir John Smale in their efforts to exterminate slavery, rather, by
their indifference and ignorance, greatly added to the obstacles put
in their way by unworthy officials.
The story we have to relate cannot in any fairness be used as an
arraignment of British Christianity excepting as we have already
indicated as to local conditions. The record that British Christian
philanthropists have made, under the leadership of the now sainted
Mrs. Josephine Butler, in their world-wide influence for purity, needs
no eulogy from our pen. It is known to the world. May Americans strive
with equal energy against conditions far more hopeful of amendment,
and we will be content to leave the issue with God.
It was our purpose when we undertook the task of writing a sketch
which would enable Americans to understand the social conditions that
are being introduced into our midst from the Orient, merely to make
a concise, brief statement of social conditions in Hong Kong out of
which these have grown, drawing our information from State Documents
of the British Government that we have had for some time in our
posse

have in the widest terms abolished slavery throughout the British
    dominions." "These Acts declare it unlawful for anyone owing
    allegiance to the British Crown, whether within or without the
    dominions of the Crown, to hold or in any way deal in slaves, or
    to participate in any way in such dealing, or to do any act which
    would contribute in any way to enable others to hold or deal in
    slaves. This simple declaration, if it stood alone, would make
    every act of slave-holding a misdemeanour, but the Acts themselves
    make it piracy, felony, or misdemeanour, as the case may be, to
    do any of the acts declared to be unlawful. These Acts further
    declare that persons holden in servitude as pledges or pawns for
    debt shall, for the purpose of the Slave Trade Acts, be deemed and
    construed to be slaves, or persons intended to be dealt with as
    slaves. Hundreds of persons are held in such servitude as pledged
    or pawned in Hong Kong, and not one of the parties to such
    transactions has ever been proceeded against under these Acts."
    "In addition to the above-mentioned Acts of George, William and
    Victoria, there is also the Imperial Act, entitled The Slave
    Trade Act, 1873, which consoli

a prostitute
    of her own free will. The inspector said that that was the
    description of themselves that nearly all prostitutes give, and
    that it was very rarely that it was true. The further evidence
    went to prove that she and a young man were mutually attached to
    each other, and he was anxious to redeem her, and that she was
    desirous of being redeemed, but that the price asked, two thousand
    three hundred dollars, was more than he was willing to give,
    though he was willing to give two thousand dollars.... There is
    little doubt that his inability to redeem her caused her to commit
    suicide.... The pocket-mother was not produced [at the inquest],
    and there was a general disposition on the part of the Chinese
    witnesses to withhold information."
Lord Ripon said in his letter of inquiry: "If the facts were as stated
in the above-mentioned paper, it would seem to prove that it is not
generally understood in the Colony that a brothel keeper has no legal
righ