|
I don't get it[^]
led mike
|
|
|
|
|
I want to show images in each subitem in List view of style report. I am able to show the image at the beginning of the subitem by SetImag API, but I want to place the image at the end. The image should be after the text. How can I do that?
|
|
|
|
|
See the documentation for the OWNER_DRAW style. Also there will be samples and examples on MSDN and probably here on CodeProject as well.
led mike
|
|
|
|
|
I have more than 500 controls and for each of them i need to display tool tip, for this I have stored the tool tip data(min, max values) for every control in string table, now how do I display that stored data as tool tip dynamically?
-- modified at 10:58 Monday 26th March, 2007
|
|
|
|
|
how the user defined cursors & icons can be impliment in application window in SDK
I did create an cursor
stored it in project file
open it with note pad
save the cursore ID.
include the resourse file in program.
add the .rc file in resorse file & main code in header file
use the LoadCursor(hInstance,IDC_CURSOR1); in WinMain stuff.
Eventhough i m getting error " Undeclare IDC_CURSOR1
Plz help
Regards,
Shailesh Sali,
Response Team,
MH-GOA circle
Reliance Communication.
|
|
|
|
|
its_me_shailesh wrote: Implimentation of user defined cursor & icon in application window.
Replace ur LoadCursor call with the follwing:
LoadCursor(hInstance,MAKEINTRESOURCE(IDC_CURSOR1)); // should work now
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
its_me_shailesh wrote: Eventhough i m getting error " Undeclare IDC_CURSOR1
This indicates, you have not included resource header, where it needed.
its_me_shailesh wrote: use the LoadCursor(hInstance,IDC_CURSOR1);
As already shown, use macors MAKEINTRESOURCE .
|
|
|
|
|
Hi all,
How can I remove a null character froma array of charater pointers.
See the thing is I'm reading data from a file, and sending the data over TCP/IP to the host, and the host writes the data to a file, but the data in the file looks all funny, with a strange little charater (null 0x00).
How can I remove that from every element in the array?
Many Thanx
Regards,
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
My Blog: ^_^
|
|
|
|
|
You could replace it with a space. Or, you could use memcpy to move your memory down so it's just gone ( this is more expensive ).
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
I need help with the following code that will also output the warmest and coldest days entered:
#include "stdafx.h"<br />
#include "hightemp.h"<br />
#include <vector> <br />
#include <fstream><br />
#include <iostream><br />
#include <iomanip><br />
#include <string><br />
<br />
<br />
using namespace std;<br />
CWinApp TheApp;<br />
<br />
<br />
<br />
int main()<br />
{<br />
vector <int> daily_temp(31,0);
int num_values;
int index;
double average_high;
int total = 0;
<br />
do
{<br />
cout << "Enter the number of days for which you have data: ";<br />
cin >> num_values;<br />
if ((num_values < 1) || (num_values > 31))<br />
{<br />
cout << "The number of days must be in the range 1 to 31"<br />
<< endl;<br />
}<br />
} while ((num_values < 1) || (num_values > 31));<br />
<br />
for(index = 0; index <= (num_values - 1); index++)<br />
{<br />
cout << "Enter the high temperature for day " << index + 1 << ": ";<br />
cin >> daily_temp[index];
}<br />
<br />
cout << "The array contains high temperatures for " << num_values<br />
<< " days.\n";<br />
cout << "The values are as follows.\n";<br />
for(index = 0; index <= (num_values - 1); index++)<br />
{<br />
cout << "Day " << index + 1 << ": " << daily_temp[index] << endl;<br />
total = total + daily_temp[index];
}<br />
<br />
average_high = double(total) / double(num_values);<br />
<br />
cout.setf(ios::fixed);<br />
cout << "The average high temperature during the " << num_values<br />
<< "-day period was " << setprecision(2) << average_high<br />
<< " degrees.\n";<br />
<br />
return 0;<br />
}<br />
|
|
|
|
|
Can you tell what problem you are facing ?
|
|
|
|
|
I have no problem with the code when compiled, I just need help on how to output the high and low temperature
|
|
|
|
|
Each time you enter a new temperature, you check with the previous one entered if it is bigger or lower.
|
|
|
|
|
klutez123 wrote: // The following loop gets the high temperatures from the user for as
// many days as the user specified in num_values.
for(index = 0; index <= (num_values - 1); index++)
{
cout << "Enter the high temperature for day " << index + 1 << ": ";
cin >> daily_temp[index]; // input value into array
}
How about:
int low = 500;
int high = -500;
for (index = 0; index <= (num_values - 1); index++)
{
cout << "Enter the high temperature for day " << index + 1 << ": ";
cin >> daily_temp[index];
if (daily_temp[index] > high)
high = daily_temp[index];
else if (daily_temp[index] < low)
low = daily_temp[index];
}
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
We can't see many of the < or > characters in you post or what's between them; please revise and correct your post.
Steve
|
|
|
|
|
hello,
i want to get the mouse position outside of my window, for example with windows messages.
i can't find the funktion or some code for this.
can someone help me?#
thx
|
|
|
|
|
Isn't it GetCursorPos ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Use GetCursorPos . Convert screen co-ordinates you will get to client co-ordinates.
|
|
|
|
|
I probably should be avoiding this, knowing that a request for a code sample might follow, but have you tried browsing the MSDN for "GetCursorPos", or anything containing the word "cursor"?
If not, please also try to remember from now on, that the "mouse" in most programming languages is referred to as "cursor".
The mouse is the device controlling the cursor. It's position on your desktop is not known by the system. ;) I.e, Unless you tell it you're left handed, it couldn't care less.
Cheers,
Gabriel
|
|
|
|
|
Hello,
I have created a windows service application in windows XP and VC++.Net.
In this windows service application, i am connecting to MySQL database on the same computer. My application is to get the USB plug-n-plays. I am opening the MySQL db not in the ServiceMain() of the service, rather, since i have to every time check for the database connection, so in case of everyrequirement.. i am opening the database and throwing the exception, on db connection failure.
I can see that, everytime the statement :
usbDB.OpenEx(szConnectString_USB,CDatabase::noOdbcDialog); is throwing the exception.
in the catch() block i reported the error too, but it is not displaying the error report.
After that, i restarted the system and then i see that, when i follow the debugger, the breakpoint at the usbDB.OpenEx(..) is not getting triggered.
myServiceMain(int arg, char *argv)
{
hStatus=RegisterServiceCtrlHandler(szServiceName, handlerFunc);
SetServiceStatus(hStatus, &ServiceStatus);
initService();
....
....
RegisterDeviceNotification(hStatus),&NotificationFiler,DEVICE_NOTIFY_SERVICE_HANDLE);
....
....
while(ServiceStatus.dwCurrentStatus=SERVICE_RUNNING)
{
/*do my task*/
....
....
}
ServiceStatus.dwCurrentStatus=STOPPED;
SetServiceStatus(hStatus,&ServiceStatus);
}
InitService()
{
/* intialisation code for my Service*/
}
I think, in the MyServiceMain(..) the code after the RegisterServiceCtrlHandlerEx(...) is not getting executed. So, the breakpoint kept inside the InitService() is not getting called. Even the breakpoint inside the MyServiceMain() is also not getting called. To trigger the breakpoints in the MyServiceMain() callback function, when i am stopping and restarting or restarting the service from the control panel... the service is not getting stopped ..it is only showing that... "stopping".
I have checked the dsn name, user id and password also... but i don know why, it is not getting connected to my windows service application.
Thank you
Anee
Anee
|
|
|
|
|
anumadhu wrote: myServiceMain(int arg, char *argv)
{
hStatus=RegisterServiceCtrlHandler(szServiceName, handlerFunc);
SetServiceStatus(hStatus, &ServiceStatus);
Are you initializing the contents of ServiceStatus somewhere? Also, if connecting to your database (not shown in the code you included) can take a noticeable period of time, you should do it AFTER you report to the SCM that your service is started.
Do you receive notification in your handlerFunc telling your service to stop? Do you handle those notification?
Judy
|
|
|
|
|
yes, i am initalizing the ServiceStatus in the myServiceMain(int arg, char**argv) itself.
i am connecting MySQL to database using this statement:
try
{
usbDB.OpenEx(szConnectString_USB,CDatabase::noOdbcDialog);
}
catch(CException *e)
{
WriteIntoLogFile("db open Exception here");// And my log file is showing this stmt as the last stmt in it.
return;
}
myServiceMain is as follows....
void myServiceMain(int argc, char **argv)
{
int result=-1;
usbObj.WriteIntoLogFile("At DataSentinelMain");
ServiceStatus.dwServiceType = SERVICE_WIN32;
ServiceStatus.dwCheckPoint = 0;
ServiceStatus.dwCurrentState = SERVICE_START_PENDING;
ServiceStatus.dwControlsAccepted =SERVICE_ACCEPT_STOP|SERVICE_ACCEPT_SHUTDOWN;
ServiceStatus.dwServiceSpecificExitCode = 0;
ServiceStatus.dwWaitHint =0;
ServiceStatus.dwWin32ExitCode = 0;
hStatus=RegisterServiceCtrlHandlerEx((LPCWSTR)SERVICE_NAME_USB,(LPHANDLER_FUNCTION_EX)ControlHandler, 0);
usbObj.WriteIntoLogFile("Aftr calling RegisterServiceCtrlHandler");
if(hStatus==(SERVICE_STATUS_HANDLE)0)
{
usbObj.WriteIntoLogFile("hstatus returned SERVICE_STATUS_HANDLE INVALID");
return;
}
SetServiceStatus(hStatus,&ServiceStatus);
usbObj.WriteIntoLogFile("before RegisterDeviceNotifications");
result=usbObj.RegisterForDeviceNotifications (hStatus);
ServiceStatus.dwCurrentState=SERVICE_RUNNING;
SetServiceStatus(hStatus,&ServiceStatus);
if(result!=1)
{
usbObj.WriteIntoLogFile("RegisterDeviceNotification returned invalid value");
return;
}
usbObj.WriteIntoLogFile("After the call of RegisterDeviceNotification");
InitService();//27March 07
usbObj.WriteIntoLogFile("After the call to InitService");
/* Enumerate the USB DEVICES */
result=0;
while(ServiceStatus.dwCurrentState = SERVICE_RUNNING)
{
result++;
usbObj.WriteIntoLogFile("Call to USBServiceFunc from While of ServiceStatus_running");
usbObj.USBService ();
usbObj.WriteIntoLogFile("after and end of USBServiceFunc");
if(result>100)
{
ServiceStatus.dwCurrentState = SERVICE_STOPPED;
SetServiceStatus(hStatus,&ServiceStatus);
return;
}
Sleep(5000);
}
ServiceStatus.dwCurrentState = SERVICE_STOPPED;
SetServiceStatus(hStatus,&ServiceStatus);
return;
}
usbObj.USBService ()
{
/*this contains a method called usbObj.OpenDevices()..where the db is opened using the above stms..*/
}
i have seen even the MySQL.. service also.. which is getting started before the start of my own service.
but still i am unable to connect to the MySQL db at my local machine.
any idea...pls?
Anee
|
|
|
|
|
Just looking at the code, I don't see anything wrong. You'll have to use the debugger and see where it's hanging up. Put a call to DebugBreak at the start of your ServiceMain - this will force a breakpoint to occur and you can then use VS to debug it.
Judy
|
|
|
|
|
Thanks Judy!
Yeah, i have even debugged this service in following way:
1) first using the exe, i created the service :
sc create MyService binpath= D:\MyService.exe
2) Then started it from the control pannel. After it shows the status as "Started". I go to step 3.
3) Then using the Visual Studio (my development environment) + Debug + Attach Process + MyService.exe+attach.
4) And kept breakpoints in the starting of the MyServiceMain() and at the while() and also at the controlHandler function.
void ControlHandler(DWORD dwServiceCtrlEvent, DWORD dwEventType,
LPVOID lpEventData, LPVOID lpContext)
{
switch(dwServiceCtrlEvent)
{
case SERVICE_CONTROL_DEVICEEVENT:
usbObj.OnMyDeviceEvent(dwEventType,lpEventData);
break;
case SERVICE_CONTROL_STOP:
usbObj.UnRegisterEvents();
ServiceStatus.dwCurrentState = SERVICE_STOP_PENDING;//SERVICE_STOPPED;
SetServiceStatus(hStatus,&ServiceStatus);
break;
case SERVICE_CONTROL_PAUSE:
break;
case SERVICE_CONTROL_CONTINUE:
break;
case SERVICE_CONTROL_INTERROGATE:
break;
default:
break;
}
SetServiceStatus(hStatus,&ServiceStatus);
}
When i connect the USB device, then only the breakpoint is getting triggered and that too at the controlHandler()'s SERVICE_CONTROL_DEVICEEVENT. But never in or at the beginning at the MyServiceMain().
That is why, i used a WriteIntoLogFile() to get the required information regarding the order of execution of lines in my application.
Are you sure.. that my code have no errors?? Then i am bit worried..abt the cause of problem.
Thanks in advance..
Anee
|
|
|
|
|
It sounds like the problem is at the beginning. Setting a breakpoint at the beginning of ServiceMain _after_ the service is started won't do you any good since that code has already executed. You need to use the DebugBreak function at the very start of your ServiceMain. It will force a breakpoint and the OS will allow you to select a debugger to attach to the process - in this case your service. You can then debug your startup logic which, by your description, is where your problem is.
I don't know that your code doesn't have any errors. In a visual inspection, I don't see one but I don't know what your problem domain is and your thinking about how your code solves that problem. I don't have your whole program nor do I want you to post it. Your problem is at the beginning - you need to debug that, conparing your intended logic flow with what your code actually does. The only way to debug the beginning of a service is by using the DebugBreak .... or coding an infinite loop and attaching the debugger as you are already doing and then breaking the loop. Use DebugBreak
Judy
|
|
|
|