f



windows in c

this is not oftopic becouse imagine there would be no windows 
systems yet made (like windows,linux,mac) and one would like to make it then would need to design small windows api for handling that - and i wonder what options are there and which one would be better 

i present my thoughts which i thinki are practically interesting 
and increase knowledge about c windows environments 

1)  topic - how should behave such program in a windows environment 
  
  void main() { 
   printf("hello world"); } 

there is a problem 1) if such program should open a console 
window ? 2) should never print nothing? 3) should maybe print something if run from console only? 

imo the options 1 or 3 are probably more good, hard to decide 
which one would be better, posibly maybe 3 (? ) 

right now afair this works different i mean this creates console  window or no based of compile/linkind switch (this seems bad ) 

[if someone is knowlegeable or has opinion on this - may comment] 

2) how the simplest non console window program should like 
(excluding empty) i mean soreta real app suited to windows 

 void main() 
{ 
    for(;;) 
     sleep(10); 
} 

 this imo could be base as windows so called service, i constanlty mean runing program which not opens a window , 

such services may be usefull for something, though im not sure for what (got no experience coding services) 
  
ofc it should poll on some info like for example current 
date and time etc 
(sleep is ofc not much good name, maybe it should be named 
like system(), give_cpu_to_system() or what 

3) how minimal app with real window should look like 
  
 void main() 
 { 
    SetupWindow("window1",500,400); 

    for(;;) 
    { 
     sleep(10); 
    } 
    
 } 

 such windows could not react on events, like resize keypresses or mouse clicks - so polling or registering handler is needed 

im not sure how polling would really work, probably same as handler,  some 

 pull_event(&event); 

would be needed, im not sure if such filled queue of events 
as in winapi is trong need or it could really look some 
other way (?) 

polling could really be maybe a bit less confusing than callback 

this opens btw some more area for thinking as for example 
this way of making windows seem at all a bit weird becouse in reality window belongs to system (like program body) it also makes all interchanges betwean desctop and those window and programmer program part is weirdly parted client of that window 
(at least it gets me a bit thinking (in methaforic way, uh uh )) 

Some thoughts? 

could maybe someone write a quick how this windows handling looks on linux (and eventually mac)  (or at least maybe give some link to clear article?) 
0
fir
12/16/2016 6:30:57 PM
comp.os.programmer.win32 14523 articles. 0 followers. Post Follow

1 Replies
226 Views

Similar Articles

[PageSpeed] 6

On Fri, 16 Dec 2016 10:30:57 -0800 (PST), fir wrote:
> 
> 1)  topic - how should behave such program in a windows environment 
>   
>   void main() { 
>    printf("hello world"); } 
> 
> there is a problem 1) if such program should open a console 
> window ? 2) should never print nothing? 3) should maybe print something if run from console only? 
> 
> imo the options 1 or 3 are probably more good, hard to decide 
> which one would be better, posibly maybe 3 (? ) 
> 
> right now afair this works different i mean this creates console  window or no based of compile/linkind switch (this seems bad ) 
> 
> [if someone is knowlegeable or has opinion on this - may comment] 

Have that program be compiled as a windowless GUI program (i.e. non console)
and have it provide a command line switch for displaying a console window or
not.

But beware. Unlike console programs, starting a GUI program from a command
prompt will return to the prompt immediately.

> 2) how the simplest non console window program should like 
> (excluding empty) i mean soreta real app suited to windows 
> 
>  void main() 
> { 
>     for(;;) 
>      sleep(10); 
> } 
> 
>  this imo could be base as windows so called service, i constanlty mean runing program which not opens a window , 
> 
> such services may be usefull for something, though im not sure for what (got no experience coding services) 
>   
> ofc it should poll on some info like for example current 
> date and time etc 
> (sleep is ofc not much good name, maybe it should be named 
> like system(), give_cpu_to_system() or what 

The main disadvantage of such simple program is that it won't be alertable.
e.g. It won't be able to respond to notifications such as user log off or
system shutdown/restart - whether it's OK to log off, or shutdown/restart.
Thus, the program may interfere that system task - forcing the OS to display
a dialog box saying that your program is not responding.

> 3) how minimal app with real window should look like 
>   
>  void main() 
>  { 
>     SetupWindow("window1",500,400); 
> 
>     for(;;) 
>     { 
>      sleep(10); 
>     } 
>     
>  } 
> 
>  such windows could not react on events, like resize keypresses or mouse clicks - so polling or registering handler is needed 
> 
> im not sure how polling would really work, probably same as handler,  some 
> 
>  pull_event(&event); 
> 
> would be needed, im not sure if such filled queue of events 
> as in winapi is trong need or it could really look some 
> other way (?) 
> 
> polling could really be maybe a bit less confusing than callback 
> 
> this opens btw some more area for thinking as for example 
> this way of making windows seem at all a bit weird becouse in reality window belongs to system (like program body) it also makes all interchanges betwean desctop and those window and programmer program part is weirdly parted client of that window 
> (at least it gets me a bit thinking (in methaforic way, uh uh )) 
> 
> Some thoughts? 
> 
> could maybe someone write a quick how this windows handling looks on linux (and eventually mac)  (or at least maybe give some link to clear article?)

See below MSDN article.

<https://msdn.microsoft.com/en-us/library/windows/desktop/ms644928(v=vs.85).aspx#creating_loop>
0
JJ
12/19/2016 5:14:08 PM
Reply: