|
MSDN says "PeekMessage does not retrieve messages for windows that belong to other threads.". So, the messages from your queue will not be removed by others. They will be in queue till you Peek or Get messages. And you can not PeekMessage from a window queue, where the window is not created by your thread
|
|
|
|
|
thanks.
ramana.g wrote: MSDN says "PeekMessage does not retrieve messages for windows that belong to other threads.". So, the messages from your queue will not be removed by others. They will be in queue till you Peek or Get messages. And you can not PeekMessage from a window queue, where the window is not created by your thread
AS far as I know, all my windows and all my application is one thread.
|
|
|
|
|
Thank you all for help and invaluable knowledge !!!
I sure learned a lot.
It turns out, I stuck too much in the case WM_PAINT: ,
and that clogged the WM_TIMER messages.
I rendered all my windows on WM_PAINT (DirectX stuff).
Now, When I drag my windows some ungraceful visual effects happen, but I guess
I'll manage.
|
|
|
|
|
I want to draw a 3D cube without using graphics libraries such as OpenGL. I`m not sure how I can draw the cube. I don`t know what I need to do to draw something 3D.
|
|
|
|
|
See if you can pick yourself up a copy of the book 'Teach Yourself Computer Graphics' or something similar. This will show you how transform a 3D point x,y,z into a 2D point X,Y using a projection. The process uses matrices so you might want to be familiar with simple matrix transformations. Many texts on DirectX also explain this sort of thing but you don't have to use DirectX to take advantage of them if you're prepared to hand code the data structures yourself. Otherwise you might want to try old school drawing in VB6, you can draw directly onto a form pretty easily. I used this to port a simple 3D scene generator from QuickBasic to Windows quite a few years ago. Provided you can handle the mathematics 3D vector drawing is not really so difficult. When it comes to more complex stuff like lighting and shading you're going to need a good book you can follow as the algorithms can be tricky.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
You have to map cube 3D coords into screen 2D ones, you may choose, for instance, perspective transformation or (the simpler) isometric one.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Hi Experts,
How can I Restart my system programtically?
|
|
|
|
|
ExitWindowsEx()[^]
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
see [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
see this [^]
|
|
|
|
|
how can i create a new process in c
|
|
|
|
|
Use the Windows API CreateProcess .
Maxwell Chen
|
|
|
|
|
|
use:
<br />
int system(<br />
const char *command <br />
);<br />
head file: <process.h> or <stdlib.h>
|
|
|
|
|
I'm very rusty - haven't coded C/C++ since 1994 - and I'm sure there's a simple answer, but I can't find it.
I'm not using 'string' support. Just the old char* methods, and the code is behaving well except when I tried to convert a keyboard virtual key code to a it's ascii character I got a runtime access violation.
The 'break' option showed me the site of the infraction - inside some MS code located in the midst of some UNICODE related logic, judging by the Defines.
I included <ctype.h>, but it didn't help.
The related trimmed code follows:
char c;
c = (char)__toascii(keyCode);
keyCode = p->vkCode;
The offending later statement is:
nLen = fprintf(fOut,"kcK=%d ud=%s kc=%d sh=%d ti=%d %s\n",cb.kcK,updn,keyCode,Shift,tick, c);
The following statement works perfectly (as above, but no c at the end)
nLen = fprintf(fOut,"kcK=%d ud=%s kc=%d sh=%d ti=%d %s\n",cb.kcK,updn,keyCode,Shift,tick);
Searched the articles and FAQ but didn't find anything.
Hope you can give me a hand here.
BTW, I want to stay in the char* arena rather than strings, for now.
I'm using Visual C++ 2003 and running Win2K SP4
One more thing - I'm logged in under my old email glyfyx@storm.ca but I have a new address, glyfix@storm.ca. I guess I should change it at Code Project?
Thanks
glyfyx
|
|
|
|
|
If c is a char , you should use %c . That's all.
Maxwell Chen
|
|
|
|
|
|
Mark Salsbery wrote: I forgot about %c....do you need to cast the c argument to an int when it's passed as
an argument for %c?
No, not needed. Simply this way is fine.
char a = 65;
printf("%c \n", a);
Maxwell Chen
|
|
|
|
|
Cool thanks!
Cheers,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Of course, %c for char! I was sure it had a simple answer but couldn't see it for looking - most embarrassing. Too many years of VB?
So big thanks Maxwell and Mark! Also Mark, I was starting to think of assembling a 2 byte char array as you suggested - that'd work with %s.
Also special thanks to Rajkumar R for the ToAscii suggestion, which is intriguing to say the least, since it requires a GetKeyboardState call to set its 256 byte array arg, lpKeyState, to the current status of *all* the virtual keys. I would have thought GetKeyState for just the virtual key in question (1st arg, uVirtKey),would be sufficient.
I suppose ToAscii will be a case-sensitive conversion - will give it a shot and see what happens.
int ToAscii(
UINT uVirtKey,
UINT uScanCode,
PBYTE lpKeyState,
LPWORD lpChar,
UINT uFlags
);
Here's the MSDN article...
http://msdn2.microsoft.com/en-us/library/ms646299(VS.85).aspx
Thanks again everyone!
glyfyx
|
|
|
|
|
glyfyx wrote: I tried to convert a keyboard virtual key code to a it's ascii character
if you are converting from Keyboard Virtual KeyCode, use
int ToAscii(
UINT uVirtKey,
UINT uScanCode,
PBYTE lpKeyState,
LPWORD lpChar,
UINT uFlags
);
glyfyx wrote: The offending later statement is:
nLen = fprintf(fOut,"kcK=%d ud=%s kc=%d sh=%d ti=%d %s\n",cb.kcK,updn,keyCode,Shift,tick, c);
format specifier is %s and passing char, c.
|
|
|
|
|
The arguments you pass to fprintf() need to match the format specifiers in the
format control string, in both type and number of arguments.
All the "%d"s in the format control string need a corresponding 32-bit integer argument passsed...
All the "%s"s in the format control string need a corresponding pointer to a null-terminated string passed.
The version where you don't pass the c argument only appears to work, since you pass 5 arguments
when the format control string specifies an expected 6 arguments.
The version that crashes probably fails because c is a char but the format specifier is %s, which means
the passed argument should be a pointer to a NULL-terminated string, not a single character.
If you do something like this, it should work:
char c<font color="Red">[2]</font>;
c<font color="Red">[0]</font> = (char)__toascii(keyCode);
<font color="Red">c[1] = '\0';</font>
keyCode = p->vkCode;
...
nLen = fprintf(fOut,"kcK=%d ud=%s kc=%d sh=%d ti=%d %s\n",cb.kcK,updn,keyCode,Shift,tick, c);
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
In Button event I wrote ...
CMatlabEng matlab;
matlab.Open(NULL);
But MatLab is not opening .....Plz Help me.........
#sanroop#
|
|
|
|
|
like this way i fallow ...
Open MSVisualC++.
Select Tools ->Customize from the MSVC menu.
Click on the Add-ins and Macro Files tab.
but MATLAB for Visual Studio on the Add-ins and Macro Files list is not showing...PLZ help me...How to Configure the Matlab Add-in for Visual Studio vc++ 6.0..PLZ
#sanroop#
|
|
|
|
|
Hi all
I am locking a file.First times it locks..but second time if i want to unlock..it is not unlocking the file..plz help me ..here is the code....
int LockFile(char *cFileName, bool bLock)
{
int iFile;
if(bLock)
{
iFile = _open(strcat(cFileName, ".lck"), _O_CREAT | _O_EXCL | _O_RDWR);
_close(iFile);
if(iFile < 0)
{
printf("File locked by another process");
return -1;
}
printf("File is locked for writting");
return iFile;
}
else
{
iFile = remove(strcat(cFileName, ""));
if(iFile == -1)
{
printf("Error in file unlocking");
return -1;
}
printf("File unlocking successfull");
}
return iFile;
}
int main(int argc, char* argv[])
{
char strFilePath []= {"E:\\Add_Modified_ENG\\test.txt"};
char *cFilePath = strFilePath;
int i = LockFile(strFilePath, true);
if(i != -1)
{
ofstream outfile(cFilePath, ios::app);
if(!outfile)
{
cout<<"Unable to open\n";
return 1;
}
outfile<<"Test";
outfile.close();
}
i = LockFile(strFilePath, false);
return 0;
}
Hi,,
I am sharan.Working as a software Engineer in Indo-Fuji Software Company located in BTM Layout.Bangalore.India.
I have Completed my B.E(COmputers)in 2006.ANd I am having 2 years of Exp in VC++.
thanking you
sharan
|
|
|
|
|