|
chopeen wrote:
Try to be more precise.
If it is a dialog-based application, you can call Start() method in CYourAppDlg::OnInitDialog().
Sorry i didn't be more precise.
Yes, it is a dialog based application
here is the code that i was calling for the case to start the app when i click Start or Stop ect.,
that is in my "led.c" file
<br />
BOOL CALLBACK DialogProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)<br />
{<br />
if(wParam==SYSTRAYBUTTON&&(lParam&3)==3) {<br />
<br />
Shell_NotifyIcon(NIM_DELETE,&nidata);<br />
ShowWindow(hDialog,SW_SHOW);<br />
<br />
SetForegroundWindow(hDialog);<br />
}<br />
<br />
switch (message) {<br />
case WM_INITDIALOG:<br />
return TRUE;<br />
case WM_COMMAND:<br />
switch(LOWORD(wParam)) {<br />
case IDRELOAD:<br />
timeKillEvent(timerid);<br />
load_cfg();<br />
curtimes=0;<br />
curframes=0;<br />
curtime=0;<br />
curframe=0;<br />
change=0;<br />
timerid=timeSetEvent(current->delay,current->delay,TimeProc,0,TIME_PERIODIC);<br />
return TRUE;<br />
case IDHIDE:<br />
ShowWindow(hDialog,SW_HIDE);<br />
Shell_NotifyIcon(NIM_ADD,&nidata);<br />
return TRUE;<br />
case IDEXIT:<br />
PostQuitMessage(0);<br />
return TRUE;<br />
case IDSTOP:<br />
timeKillEvent(timerid);<br />
return TRUE;<br />
case IDSTART:<br />
timerid=timeSetEvent(current->delay,current->delay,TimeProc,0,TIME_PERIODIC);<br />
return TRUE;<br />
case IDCLEAR:<br />
timeKillEvent(timerid);<br />
{<br />
char *buf;<br />
buf=calloc(64,1);<br />
refresh(buf);<br />
free(buf);<br />
}<br />
return TRUE;<br />
default:<br />
return FALSE;<br />
}<br />
case WM_DESTROY:<br />
case WM_CLOSE:<br />
PostQuitMessage(0);<br />
}<br />
return FALSE;<br />
}<br />
and this is what it look like when in dialog
http://thanhmai.virtualave.net/led.jpg[^]
and all i want to do it let the Program to run when i open the program.
Thanh
|
|
|
|
|
I guess that this happens when you press the Go button:
case IDSTART:<br />
timerid=timeSetEvent(current->delay,current->delay,TimeProc,0,TIME_PERIODIC);<br />
return TRUE;
Am I right? If yes, put the timerid=timeSetEvent... line in WM_INITDIALOG . You will have something like this:
case WM_INITDIALOG:<br />
timerid=timeSetEvent(current->delay,current->delay,TimeProc,0,TIME_PERIODIC);<br />
return TRUE;
This should do the trick. If it does, let me know. And if it doesn't, you can send me the code and I'll work it out.
modified on Monday, August 30, 2010 6:32 AM
|
|
|
|
|
chopeen wrote:
I guess that this happens when you press the Go button:
case IDSTART:
timerid=timeSetEvent(current->delay,current->delay,TimeProc,0,TIME_PERIODIC);
return TRUE;
Am I right? If yes, put the timerid=timeSetEvent... line in WM_INITDIALOG. You will have something like this:
case WM_INITDIALOG:
timerid=timeSetEvent(current->delay,current->delay,TimeProc,0,TIME_PERIODIC);
return TRUE;
This should do the trick. If it does, let me know. And if it doesn't, you can send me the code and I'll work it out.
Hi chopeen,
Yes, you are right it happen when you press the Go button: i have try to use your method and it didn't work it compile and when i try to run the app i get and Application Error
"The instruction at "0x00401447" referenced memory at "0x00000008". The memory could not be "read".
here is what i add to the code:
switch (message) {<br />
case WM_INITDIALOG:<br />
timerid=timeSetEvent(current->delay,current->delay,TimeProc,0,TIME_PERIODIC);<br />
return TRUE;
maybe i try it again tomorrow, right now is 4:00 AM and i just get back home from work and check the message and try it see it work but not.
here is a block section of the code that the DIALOG INIT
BOOL CALLBACK DialogProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)<br />
{<br />
if(wParam==SYSTRAYBUTTON&&(lParam&3)==3) {<br />
<br />
Shell_NotifyIcon(NIM_DELETE,&nidata);<br />
ShowWindow(hDialog,SW_SHOW);<br />
<br />
SetForegroundWindow(hDialog);<br />
}<br />
<br />
switch (message) {<br />
case WM_INITDIALOG:<br />
return TRUE;<br />
case WM_COMMAND:<br />
switch(LOWORD(wParam)) {<br />
case IDRELOAD:<br />
timeKillEvent(timerid);<br />
load_cfg();<br />
curtimes=0;<br />
curframes=0;<br />
curtime=0;<br />
curframe=0;<br />
change=0;<br />
timerid=timeSetEvent(current->delay,current->delay,TimeProc,0,TIME_PERIODIC);<br />
return TRUE;<br />
case IDHIDE:<br />
ShowWindow(hDialog,SW_HIDE);<br />
Shell_NotifyIcon(NIM_ADD,&nidata);<br />
return TRUE;<br />
case IDEXIT:<br />
PostQuitMessage(0);<br />
return TRUE;<br />
case IDSTOP:<br />
timeKillEvent(timerid);<br />
return TRUE;<br />
case IDSTART:<br />
timerid=timeSetEvent(current->delay,current->delay,TimeProc,0,TIME_PERIODIC);<br />
return TRUE;<br />
case IDCLEAR:<br />
timeKillEvent(timerid);<br />
{<br />
char *buf;<br />
buf=calloc(64,1);<br />
refresh(buf);<br />
free(buf);<br />
}<br />
return TRUE;<br />
default:<br />
return FALSE;<br />
}<br />
case WM_DESTROY:<br />
case WM_CLOSE:<br />
PostQuitMessage(0);<br />
}<br />
return FALSE;<br />
}<br />
Thank you the help
Thanh
|
|
|
|
|
Looks like the current object (whatever it is) is not initialized, when you start your app.
It means that there is something before IDSTART that does it.
modified on Monday, August 30, 2010 6:39 AM
|
|
|
|
|
i have get it to work finally
i have to add it at the end of my loading the script file
Thank for the help chopeen.
Thanh
<br />
load_cfg();<br />
#ifdef DEBUG<br />
mem_debug();<br />
#endif<br />
<br />
{<br />
char *buf;<br />
buf=calloc(64,1);<br />
refresh(buf);<br />
free(buf);<br />
}<br />
<br />
timerid=timeSetEvent(current->delay,current->delay,TimeProc,0,TIME_PERIODIC);<br />
<br />
<br />
while (GetMessage (& msg, 0, 0, 0)) {<br />
if (!IsDialogMessage (hDialog, & msg))<br />
{<br />
TranslateMessage ( & msg );<br />
DispatchMessage ( & msg );<br />
}<br />
}<br />
<br />
<br />
Shell_NotifyIcon(NIM_DELETE,&nidata);<br />
return 0;<br />
}<br />
|
|
|
|
|
Another solution is a timer.
Kuphryn
|
|
|
|
|
thank, but i don't want to do with any timer
my program have a time delay when it open up and it init the dll driver for
parallel port and then it load the ledcfg.txt and it sit there until i click
start the program.
Thanh
|
|
|
|
|
Using Microsoft .NET 2003, Visual C++
After compiling a project, when I run the project, I get a dialogbox saying the project is out of date and if I want to comile it.
If I respond Yes, it seems to be compiling the resources. I've checked the dates of resource files, all seems ok.
What can be causing that ?
happy holidays.
|
|
|
|
|
I found my problem...
There was a conditional compile directive in the .RC file that was spanning on two lines with a '\' line break. I removed the '\' line break so that the directive fits only on one line. That made the 'out of date' message go away.
I found this line by looking at the BuildLog.htm result file. There was an entry stating that a file 'define(_DEBUG))' could not be found.
Not to sure how this happened. I never edited that file by hand. This project was converted from VC6 to VC.NET by VC.NET, but was not doing that problem after convertion. Happend at some point after.
anyways, it is solved. Thought I was going crazy
Thanks for the spiritual support
Louis.
---
Now...how to rate this one ?
|
|
|
|
|
LIBCMT.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/WinMain.exe : fatal error LNK1120: 1 unresolved externals
I have always had my suspicions about VB
|
|
|
|
|
|
Try running the following: (I bought a book, programming role playing games with directx and this is the first sample, one problem, it gives me an error, this is off the cd:
/**************************************************
WinMain.cpp
Chapter 5 Shell Application
Programming Role-Playing Games with DirectX
by Jim Adams (01 Jan 2002)
**************************************************/
// Include files
#include <windows.h>
#include <stdio.h>
// Window handles, class and caption text
HWND g_hWnd;
HINSTANCE g_hInst;
static char g_szClass[] = "ShellClass";
static char g_szCaption[] = "Shell Application";
// Function prototypes
int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev,
LPSTR szCmdLine, int nCmdShow);
long FAR PASCAL WindowProc(HWND hWnd, UINT uMsg,
WPARAM wParam, LPARAM lParam);
BOOL DoInit();
BOOL DoShutdown();
BOOL DoFrame();
int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev,
LPSTR szCmdLine, int nCmdShow)
{
WNDCLASSEX wcex;
MSG Msg;
g_hInst = hInst;
// Create the window class here and register it
wcex.cbSize = sizeof(wcex);
wcex.style = CS_CLASSDC;
wcex.lpfnWndProc = WindowProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInst;
wcex.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = NULL;
wcex.lpszMenuName = NULL;
wcex.lpszClassName = g_szClass;
wcex.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
if(!RegisterClassEx(&wcex))
return FALSE;
// Create the Main Window
g_hWnd = CreateWindow(g_szClass, g_szCaption,
WS_CAPTION | WS_SYSMENU,
0, 0, 400, 400,
NULL, NULL,
hInst, NULL );
if(!g_hWnd)
return FALSE;
ShowWindow(g_hWnd, SW_NORMAL);
UpdateWindow(g_hWnd);
// Run init function and return on error
if(DoInit() == FALSE)
return FALSE;
// Start message pump, waiting for signal to quit
ZeroMemory(&Msg, sizeof(MSG));
while(Msg.message != WM_QUIT) {
if(PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE)) {
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
if(DoFrame() == FALSE)
break;
}
// Run shutdown function
DoShutdown();
UnregisterClass(g_szClass, hInst);
return Msg.wParam;
}
long FAR PASCAL WindowProc(HWND hWnd, UINT uMsg, \
WPARAM wParam, LPARAM lParam)
{
switch(uMsg) {
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
BOOL DoInit()
{
return TRUE;
}
BOOL DoShutdown()
{
return TRUE;
}
BOOL DoFrame()
{
return TRUE;
}
I have always had my suspicions about VB
|
|
|
|
|
It Compiles and runs No Errors
Make a Fresh WIN32 App and then try
(Are you sure you didn't modified any project settings ?)
Live as if your were to die tomorrow. Learn as if you were to live forever.
-Mahatma Gandhi
|
|
|
|
|
As a Winapp non-professional programmer, off and on for personal projects for many years, I've always tried to use the Win32 API as directly as possible. So...I've kinda disliked the whole MFC concept for quite some time. Yep, Petzold's first books were my programming bibles.
Unfortunately, MFC doesn't seem to be going away and my current project requires the use of parts of it (especially for easy CDatabase functions). Therefore, the app will be written in the "Microsoft ordained" MFC style...
The app requires high-performance threads that are used to compute millions of FLOPS. This is where using the traditional Win32 API calls was nice.
Are there any performance penalties when using MFC as it "wraps" so much stuff into the code behind-the-scenes?? In other words, is it to be expected that MFC programs operate at 80 to 90% of their straight Win32 counterparts??
Like I said, it was always more fun (and less worrisome) to get as close to direct access to the hardware as possible.
Thanks!
Joe
|
|
|
|
|
jdgonko wrote:
Are there any performance penalties when using MFC as it "wraps" so much stuff into the code behind-the-scenes?? In other words, is it to be expected that MFC programs operate at 80 to 90% of their straight Win32 counterparts??
a) You can use the bare minimum of MFC you want to, and still call straight into the Win32 API - and you can usually pull any required handles straight out of any MFC objects you have.
b) Lower application performance is an acceptable trade-off for a similar reduction in development time. MFC isn't in my experience particularly slow, as most of the calls in MFC are pretty "thin" and usually go straight into the matching Win32 calls anyway. Add in the extra useful bits (CString and the collection classes), and you save yourself a lot of headaches
--
Ian Darling
"The moral of the story is that with a contrived example, you can prove anything." - Joel Spolsky
|
|
|
|
|
Thanks, Ian, for the information regarding the use of MFC versus the Win32 API. It sounds like the MFC "objectification" of various Win32 API functions doesn't impede the processing all that much and that's good. It reminds me of when I started to use C for Windows apps (Petzold's first book). I'd be writing in C but still need to inline some assembly code to get that extra graphics performance. Now, it's C++ using MFC and "inlining" some direct Win32 API calls!! And, no direct hardware access anymore (don't know how to write my own custom device drivers yet either)...
The project I have going is a full-blown jukebox type application with DSP routines that I've learned through various books. I've left the FFT routines up to the guys of FFTW.com (they've done an excellent job fine-tuning the performance of the FFT in their libraries!!). In the current Win32 version I have going, there are separate high-priority threads for the audio playback and then the DSP math portions (if they get interrupted, you HEAR the problem, haha) and then a standard thread for the GUI.
It is only a personal project - nothing for sale - and perhaps it'll turn out good enough (and interesting enough) to be on this site in the future.
Thanks again and have a great holiday season.
Joe
|
|
|
|
|
Ian Darling wrote:
MFC isn't in my experience particularly slow, as most of the calls in MFC are pretty "thin" and usually go straight into the matching Win32 calls anyway.
Yes and The MFC Message Routing architecture is faster in some cases than a standard switch..case statement in WIN32
Live as if your were to die tomorrow. Learn as if you were to live forever.
-Mahatma Gandhi
|
|
|
|
|
I really like the class because it's so easy to use. However i have a few problems with alpha
Creating an image with:
MyImage.Create(width, height, 32, CImage::createAlphaChannel);
Results in no alpha at all and when creating like this:
MyImage.CreateEx(width, height, 32, BI_RGB, 0,CImage::createAlphaChannel);
i get a completely transparent Image even if i set every pixel to 0xffffffff.
|
|
|
|
|
Hi guys,
I use a Static Text (CEdit) as an description to an Edit Control box. I want to be able to select the text in the Edit Control box when the Static Text is clicked (whether single or double click) using mouse. I tried to add mouse click type of event handlers of the Static text. Unforunately there seems to be 0 event handlers avaiable for Static Text.
Is that the case? If so, what can I do to acheive that (I am thinking to add a different component on the top of the Static Text but make it transparent).
Please help,
Thanks in advance
|
|
|
|
|
One possible solution is to add a mouse click message to the parent window. Determine whether the mouse pointer is within the coordinates of the static text box vis PtInRect().
Kuphryn
|
|
|
|
|
|
Michael Dunn wrote:
Set the Notify style on the static control. Then when you click it, it will send a STN_CLICKED notification to its parent.
Thanks guys,
The Nofity Style seems to be much more straight and is what I have chosen to use. Works well.
Thanks again
|
|
|
|
|
Hi all...
Does any1 know how can I create win32 window in perl
|
|
|
|
|
Read the documentation of perl.
My God is more powerfull Than Your God. (the line that divides the world)
|
|
|
|
|
Hi,
I created an ATL service and added an interface to it (STA)
Now, from my client application i am creating the interface and calling one of its method, after that method call is over the service gets terminated,
Any one knows why?
My God is more powerfull Than Your God. (the line that divides the world)
|
|
|
|
|