It's back to the source .... even if sometimes it hurts the feet after a while
My dream begin....since 2 days i learning C
- Kwai chang caine
- Always Here

- Posts: 5502
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
Re: My dream begin....since 2 days i learning C
Thanks....
It's back to the source .... even if sometimes it hurts the feet after a while
It's back to the source .... even if sometimes it hurts the feet after a while
The happiness is a road...Not a destination
- flaith
- Enthusiast

- Posts: 704
- Joined: Mon Apr 25, 2005 9:28 pm
- Location: $300:20 58 FC 60 - Rennes
- Contact:
Re: My dream begin....since 2 days i learning C
The answer is ... 42Kwaï chang caïne wrote:..i want just a simple answer, at your advice at all...
(no offence KCC, just kidding)
“Fear is a reaction. Courage is a decision.” - WC
- Kwai chang caine
- Always Here

- Posts: 5502
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
Re: My dream begin....since 2 days i learning C
42
It's your age ??
It's your age ??
The happiness is a road...Not a destination
-
LuCiFeR[SD]
- 666

- Posts: 1033
- Joined: Mon Sep 01, 2003 2:33 pm
Re: My dream begin....since 2 days i learning C
hehehe, not his age, but it is the answer to the "Ultimate Question of Life, the Universe and Everything"Kwaï chang caïne wrote:42![]()
It's your age ??
- Kwai chang caine
- Always Here

- Posts: 5502
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
Re: My dream begin....since 2 days i learning C
Aaaah ok ...again a thing i don't know
http://en.wikipedia.org/wiki/42_%28number%29
How can you do all, for knowing so much things that KCC don't know
You are several life ??
In fact you have 5236 years ??? and hide your real age
So Kcc don't have an enough big head to know all of that
He just want to know if the WaitWindowsEvent is the same thing that the while (GetMessage(&msg, NULL, 0, 0)) it's all
For the 42 ...i wait a little bit for reading this ..it's a little bit simple for me

http://en.wikipedia.org/wiki/42_%28number%29
How can you do all, for knowing so much things that KCC don't know
You are several life ??
In fact you have 5236 years ??? and hide your real age
So Kcc don't have an enough big head to know all of that
He just want to know if the WaitWindowsEvent is the same thing that the while (GetMessage(&msg, NULL, 0, 0)) it's all
For the 42 ...i wait a little bit for reading this ..it's a little bit simple for me

The happiness is a road...Not a destination
-
LuCiFeR[SD]
- 666

- Posts: 1033
- Joined: Mon Sep 01, 2003 2:33 pm
Re: My dream begin....since 2 days i learning C
ROFL! KCC, I am not Krishna
... I am much older than that... closer to 4.6 billion years old hehehe
- Kwai chang caine
- Always Here

- Posts: 5502
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
Re: My dream begin....since 2 days i learning C
If you are so old .....you know surely GOD ???
The next time you eat with him....can you ask if the WaitWindowsEvent is the same thing that the while (GetMessage(&msg, NULL, 0, 0))
I'm sure that at less GOD, know that
The happiness is a road...Not a destination
-
LuCiFeR[SD]
- 666

- Posts: 1033
- Joined: Mon Sep 01, 2003 2:33 pm
Re: My dream begin....since 2 days i learning C
Sorry, I don't know this "god" you speak of?... Is he the one who threw me out of heaven? 
haha, For goodness sake KCC, if it "behaves" like waitWindowEvent(), as in it waits for a message, then it is correct... if it doesn't wait... then it is behaving like WindowEvent(). There are literally thousands if not MILLIONS of C/C++ tutorials out there
. Just learn the correct way pass the events you wish to trap
I know you think I am being horrible and teasing you, and you would be correct
BUT, I still love you old friend 
haha, For goodness sake KCC, if it "behaves" like waitWindowEvent(), as in it waits for a message, then it is correct... if it doesn't wait... then it is behaving like WindowEvent(). There are literally thousands if not MILLIONS of C/C++ tutorials out there
I know you think I am being horrible and teasing you, and you would be correct
- Kwai chang caine
- Always Here

- Posts: 5502
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
Re: My dream begin....since 2 days i learning C
Perhaps, but there are much more less tutorial about PB and his eventThere are literally thousands if not MILLIONS of C/C++ tutorials out there
My only problem is just for know if PB have the same behaviour like C in this case.
Apparently yes, because PB have WaitWindowEvent and C (GetMessage(&msg, NULL, 0, 0))
But i have asking in forum C, and nobody understand why i don't want use callback like everybody
So i can't say, it's because in MY LANGUAGE i have two possiblity for managing events
1/ WaitWindowEvent
2/ CallBack
And i'm not forced to use CallBack in my language
So for my translate, i must know if in C, it's possible to manage the event in this loop like PB
Code: Select all
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}If it's possible i continue my search, and i'm sure i found, how..
But if it's impossible, because C, don't allow that...this is not the pain i continued to search in this way, and just translate the WaitWindowEvent by a CallBack each time
So i say to me, perhaps FRED have "simply" hiding behind
Code: Select all
Repeat
Evenement = WaitWindowEvent()
Until Evenement = #PB_Event_CloseWindowDon't worry LUCIFER..i know that, but even if my friend don't want to answer me....I know you think I am being horrible and teasing you, and you would be correctBUT, I still love you old friend
At who, i can ask all my stupids questions
The happiness is a road...Not a destination
Re: My dream begin....since 2 days i learning C
It's not the same, Kwaï chang caïne. 
There are messages that hit the WndProc but not the message pump. In C++ I would use a double ended queue where new messages from both the WndProc and the message pump were put on top and old messages (processed by Wait/WindowEvent) are taken from the bottom.
Also be sure to ignore #WM_NULL.
The fun part will be adding support for threads. Obviously, you can't use the same queue for all threads!
There are messages that hit the WndProc but not the message pump. In C++ I would use a double ended queue where new messages from both the WndProc and the message pump were put on top and old messages (processed by Wait/WindowEvent) are taken from the bottom.
Also be sure to ignore #WM_NULL.
The fun part will be adding support for threads. Obviously, you can't use the same queue for all threads!
-
LuCiFeR[SD]
- 666

- Posts: 1033
- Joined: Mon Sep 01, 2003 2:33 pm
Re: My dream begin....since 2 days i learning C
and I would change to 
Code: Select all
while (GetMessage(&msg, NULL, 0, 0))Code: Select all
while(GetMessage(&Msg, NULL, 0, 0) > 0)Re: My dream begin....since 2 days i learning C
orLuCiFeR[SD] wrote:and I would changetoCode: Select all
while (GetMessage(&msg, NULL, 0, 0))Code: Select all
while(GetMessage(&Msg, NULL, 0, 0) > 0)
Code: Select all
BOOL bRet;
while( (bRet = GetMessage( &msg, hWnd, 0, 0 )) != 0)
{
if (bRet == -1)
{
// handle the error and possibly exit
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
C provides the infinitely-abusable goto statement, and labels to branch to. Formally, the goto is never necessary, and in practice it is almost always easy to write code without it. We have not used goto in this book. -- K&R (2nd Ed.) : Page 65
- Kwai chang caine
- Always Here

- Posts: 5502
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
Re: My dream begin....since 2 days i learning C
Thanks a lot my friends !!!!
I have finally my answer
It's a pity, because it would have been far too simple
And sweet and simple is not army C programming

Me i just want if it's possible to manage events like this, without passing by callback
But apparently...it's not possible 
Well, i try to always use a callback for manage events in my translate
I convert all PB events, by a callback before
by
And after convert in c, in a callback too
Thanks a lot again my all friends
I have finally my answer
Ok, so i can't use the while (GetMessage(&msg, NULL, 0, 0)) like WaitWindowEventFriend MISTREL wrote:It's not the same, Kwaï chang caïne.
There are messages that hit the WndProc but not the message pump. In C++ I would use a double ended queue where new messages from both the WndProc and the message pump were put on top and old messages (processed by Wait/WindowEvent) are taken from the bottom.
Also be sure to ignore #WM_NULL.
It's a pity, because it would have been far too simple
And sweet and simple is not army C programming
Oh lala !!! for the thread .....it's perhaps my son, or little son who coding this partFriend MISTREL wrote:The fun part will be adding support for threads. Obviously, you can't use the same queue for all threads!
Me i just want if it's possible to manage events like this, without passing by callback
Code: Select all
BOOL bRet;
while( (bRet = GetMessage( &msg, hWnd, 0, 0 )) != 0)
{
if (bRet == -1)
{
// handle the error and possibly exit
}
else
{
switch bRet
{
case HwndButton1
// handle of first button
case HwndButton2
// handle of second button
case WM_LBUTTONUP
etc ...
}
}
}Well, i try to always use a callback for manage events in my translate
I convert all PB events, by a callback before
Code: Select all
Repeat
Evenement = WaitWindowEvent()
Select Evenement
Case #xxxxxxxxx
Case #xxxxxxxx
EndSelect
Until Evenement = #PB_Event_CloseWindow
Code: Select all
Procedure WinCallback(hWnd, uMsg, wParam, lParam)
If hWnd = xxxxx
If uMsg = #xxxx
Select wParam
Case #xxxxx
EndSelect
EndIf
EndIf
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
SetWindowCallback(@WinCallback())Thanks a lot again my all friends
The happiness is a road...Not a destination
- Kwai chang caine
- Always Here

- Posts: 5502
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
Re: My dream begin....since 2 days i learning C
You don't believe that...Kcc after long time begin his dream, coding several lines in C, for begin his code to translate PB to C
So it's just the beginning, of the beginning of the start...
But i'm so happy that i want sharing my happiness with you
For the moment, i just translate some case of OpenWindows
But it's already a beginning no ?????
You can try
OpenWindow(1, 648, 417, 265, 176, "FenetrePB", #PB_Window_ScreenCentered|#WS_POPUP)
OpenWindow(1, 648, 417, 265, 176, "FenetrePB", #PB_Window_ScreenCentered|#PB_Window_SizeGadget)
OpenWindow(1, 30, 30, 100, 100, "FenetrePB", #PB_Window_SizeGadget)
OpenWindow(1, 648, 417, 265, 176, "FenetrePB")
But after..i add #PB_Window_Minimize, #PB_Window_Maximize, etc...
There are giant works...there are so much functions, FRED is not an idle
I don't know if a day i can terminate him, but i'm happy to have starting
So now, i must go to eat and sleep, or else my whife hurt me with his broomstick.
This is my little beginning works
http://erdsjb.free.fr//PureStorage/Provisoire/Pb2C.zip
But i need help of my friends for can continue my adventure
I want to create two windows not MDI in C
And i don't know how
So i have copy the CodeBlock code and paste two time the code
Putting it in two procedure, but i'm sure there are too much sentence
Furthermore, it's just the first windows who appears
Someone can help me, to reduce the code, without changing the form please,please, please
Because if you made too difficult code, KCC don't understanding it, and not move
Just simplify the lines in procedure, move the line if she's not at his place, it's already a good help for me
I don't want create the better and optimize translater of the world, just a simple translater for can passing all my numerous code from PB in C automaticaly
1/ Just make global the sentence who is for the two windows
2/ i don't know if i must managing two callback
3/ And obviously fix the bug of see only the first windows
Thanks in advance
So it's just the beginning, of the beginning of the start...
But i'm so happy that i want sharing my happiness with you
For the moment, i just translate some case of OpenWindows
But it's already a beginning no ?????
You can try
OpenWindow(1, 648, 417, 265, 176, "FenetrePB", #PB_Window_ScreenCentered|#WS_POPUP)
OpenWindow(1, 648, 417, 265, 176, "FenetrePB", #PB_Window_ScreenCentered|#PB_Window_SizeGadget)
OpenWindow(1, 30, 30, 100, 100, "FenetrePB", #PB_Window_SizeGadget)
OpenWindow(1, 648, 417, 265, 176, "FenetrePB")
But after..i add #PB_Window_Minimize, #PB_Window_Maximize, etc...
There are giant works...there are so much functions, FRED is not an idle
I don't know if a day i can terminate him, but i'm happy to have starting
So now, i must go to eat and sleep, or else my whife hurt me with his broomstick.
This is my little beginning works
http://erdsjb.free.fr//PureStorage/Provisoire/Pb2C.zip
But i need help of my friends for can continue my adventure
I want to create two windows not MDI in C
And i don't know how
So i have copy the CodeBlock code and paste two time the code
Putting it in two procedure, but i'm sure there are too much sentence
Furthermore, it's just the first windows who appears
Someone can help me, to reduce the code, without changing the form please,please, please
Because if you made too difficult code, KCC don't understanding it, and not move
Just simplify the lines in procedure, move the line if she's not at his place, it's already a good help for me
I don't want create the better and optimize translater of the world, just a simple translater for can passing all my numerous code from PB in C automaticaly
1/ Just make global the sentence who is for the two windows
2/ i don't know if i must managing two callback
3/ And obviously fix the bug of see only the first windows
Code: Select all
#include <windows.h>
/* Declare Windows procedure */
LRESULT CALLBACK WindowProcedure1 (HWND, UINT, WPARAM, LPARAM);
LRESULT CALLBACK WindowProcedure2 (HWND, UINT, WPARAM, LPARAM);
int Fenetre1(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nCmdShow);
int Fenetre2(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nCmdShow);
/* Make the class name into a global variable */
char szClassName[ ] = "CodeBlocksWindowsApp";
int WINAPI WinMain(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nCmdShow){
int message1; /* Here messages to the application are saved */
int message2; /* Here messages to the application are saved */
message1 = Fenetre1(hThisInstance, hPrevInstance, lpszArgument,nCmdShow);
message2 = Fenetre2(hThisInstance, hPrevInstance, lpszArgument,nCmdShow);
return message1;
}
int Fenetre1(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nCmdShow){
HWND hwnd; /* This is the handle for our window */
MSG messages; /* Here messages to the application are saved */
WNDCLASSEX wincl; /* Data structure for the windowclass */
/* The Window structure */
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure1; /* This function is called by windows */
wincl.style = CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof (WNDCLASSEX);
/* Use default icon and mouse-pointer */
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL; /* No menu */
wincl.cbClsExtra = 0; /* No extra bytes after the window class */
wincl.cbWndExtra = 0; /* structure or the window instance */
/* Use Windows's default colour as the background of the window */
wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
/* Register the window class, and if it fails quit the program */
if (!RegisterClassEx (&wincl))
return 0;
/* The class is registered, let's create the program*/
hwnd = CreateWindowEx (
0, /* Extended possibilites for variation */
szClassName, /* Classname */
"Fenetre 1", /* Title Text */
WS_OVERLAPPEDWINDOW, /* default window */
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window ends up on the screen */
544, /* The programs width */
375, /* and height in pixels */
HWND_DESKTOP, /* The window is a child-window to desktop */
NULL, /* No menu */
hThisInstance, /* Program Instance handler */
NULL /* No Window Creation data */
);
/* Make the window visible on the screen */
ShowWindow (hwnd, nCmdShow);
/* Run the message loop. It will run until GetMessage() returns 0 */
while (GetMessage (&messages, NULL, 0, 0))
{
/* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
/* Send message to WindowProcedure */
DispatchMessage(&messages);
}
/* The program return-value is 0 - The value that PostQuitMessage() gave */
return messages.wParam;
}
/* This function is called by the Windows function DispatchMessage() */
int Fenetre2(HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nCmdShow){
HWND hwnd; /* This is the handle for our window */
MSG messages; /* Here messages to the application are saved */
WNDCLASSEX wincl; /* Data structure for the windowclass */
/* The Window structure */
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure2; /* This function is called by windows */
wincl.style = CS_DBLCLKS; /* Catch double-clicks */
wincl.cbSize = sizeof (WNDCLASSEX);
/* Use default icon and mouse-pointer */
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL; /* No menu */
wincl.cbClsExtra = 0; /* No extra bytes after the window class */
wincl.cbWndExtra = 0; /* structure or the window instance */
/* Use Windows's default colour as the background of the window */
wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
/* Register the window class, and if it fails quit the program */
if (!RegisterClassEx (&wincl))
return 0;
/* The class is registered, let's create the program*/
hwnd = CreateWindowEx (
0, /* Extended possibilites for variation */
szClassName, /* Classname */
"Fenetre 2", /* Title Text */
WS_OVERLAPPEDWINDOW, /* default window */
CW_USEDEFAULT, /* Windows decides the position */
CW_USEDEFAULT, /* where the window ends up on the screen */
544, /* The programs width */
375, /* and height in pixels */
HWND_DESKTOP, /* The window is a child-window to desktop */
NULL, /* No menu */
hThisInstance, /* Program Instance handler */
NULL /* No Window Creation data */
);
/* Make the window visible on the screen */
ShowWindow (hwnd, nCmdShow);
/* Run the message loop. It will run until GetMessage() returns 0 */
while (GetMessage (&messages, NULL, 0, 0))
{
/* Translate virtual-key messages into character messages */
TranslateMessage(&messages);
/* Send message to WindowProcedure */
DispatchMessage(&messages);
}
/* The program return-value is 0 - The value that PostQuitMessage() gave */
return messages.wParam;
}
/* This function is called by the Windows function DispatchMessage() */
LRESULT CALLBACK WindowProcedure1 (HWND hwnd, UINT message1, WPARAM wParam, LPARAM lParam)
{
switch (message1) /* handle the messages */
{
case WM_DESTROY:
PostQuitMessage (0); /* send a WM_QUIT to the message queue */
break;
default: /* for messages that we don't deal with */
return DefWindowProc (hwnd, message1, wParam, lParam);
}
return 0;
}
/* This function is called by the Windows function DispatchMessage() */
LRESULT CALLBACK WindowProcedure2 (HWND hwnd, UINT message2, WPARAM wParam, LPARAM lParam)
{
switch (message2) /* handle the messages */
{
case WM_DESTROY:
PostQuitMessage (0); /* send a WM_QUIT to the message queue */
break;
default: /* for messages that we don't deal with */
return DefWindowProc (hwnd, message2, wParam, lParam);
}
return 0;
}
The happiness is a road...Not a destination
-
kinglestat
- Enthusiast

- Posts: 746
- Joined: Fri Jul 14, 2006 8:53 pm
- Location: Malta
- Contact:
Re: My dream begin....since 2 days i learning C
I love C....since when I started using it 23 years ago way way back
and I still use it. But if I may offer a suggestion why make a program just in C?
You should stick with GUI stuff in PB and utilize C for optimizing regions of code and make multi-panguage programs. It is what I do. Critical level code is written in C as libs and I use importc.
and I still use it. But if I may offer a suggestion why make a program just in C?
You should stick with GUI stuff in PB and utilize C for optimizing regions of code and make multi-panguage programs. It is what I do. Critical level code is written in C as libs and I use importc.
I may not help with your coding
Just ask about mental issues!
http://www.lulu.com/spotlight/kingwolf
http://www.sen3.net
Just ask about mental issues!
http://www.lulu.com/spotlight/kingwolf
http://www.sen3.net
