|
Many of the old C APIs have been deprecated. I imagine that is the majority of your errors/warnings. You can turn that off using a compiler switch (you'll have to look that up as I don't have VS available at the moment).
These aren't e-books, but they are perhaps the best books you'll find for Win32 programming without MFC:
Programming Windows by Charles Petzold
Programming Applications for Microsoft Windows by Jeffrey Richter
Note: get the older editions as the newer ones have been written with C# (which was a mistake IMHO).
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Zac Howland wrote: Many of the old C APIs have been deprecated. I imagine that is the majority of your errors/warnings. You can turn that off using a compiler switch (you'll have to look that up as I don't have VS available at the moment).
Hi , its been a while. Yea , i got petzolds book and other books too and learnt C# , and its awesome!! Way better than win32 , i can build more powerful apps way faster! Without losing my head! (thats for anyone else doing win32)
About my problem , it seems the vc express does'nt come with the PSDK.
Look at this[^]
Hope that helped someone.
Gideon
|
|
|
|
|
Is there any way to trick the C++ compiler and get the value of a non-static member variable from a static method.
e.g.
class CDummy
{
public:
int m_myInt;
static void dummy();
};
void CDummy::dummy()
{
int x = m_myInt; ????
}
Thanks!
modified 9-Mar-17 17:16pm.
|
|
|
|
|
Not without passing a reference to the instance of your class.
I Dream of Absolute Zero
|
|
|
|
|
Yes ... its called make a non-static version of the method:
class CDummy
{
public:
int m_myInt;
static void dummy(const CDummy& dum);
void dummy() const;
};
void CDummy::dummy(const CDummy& dum)
{
dum.dummy();
}
void CDummy::dummy() const
{
int x = m_myInt;
}
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Hi,
I have outlook configured on my machine.
I need to send data (textual) to one email contact only .
Means I will have some text ready at some time interval and every tiem I read the data the data should go as email to this address using my outlook config.
How can I achieve this.
pathak
|
|
|
|
|
See here and here for examples of sending e-mail.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
How to get all the URLs (links) on the web page?
Leya
|
|
|
|
|
Use the IHTMLDocument interface to retrieve the <A> elements.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
See Here[^] maybe it is some helpful to you
whitesky
|
|
|
|
|
i want to know,that as i insert a edit box on dialog box
and 10 buttons with number on them from 0 to 9.
now i want that when i press these 0-9 buttons
then that will be appear on edit box . I use a progress control on dialog box
and a dial button so that after entering numbers press dial and progress button start
moving
I want as in phone system when we press buttons they appear on screen
and when dial button is pressed phone dials.
Please mail me
|
|
|
|
|
m_sPhoneNumber += "1";
setDlgItemText(IDC_EDIT_PHONE_NUMBER,m_sPhoneNumber);
put that code on button click.
sPhoneNumber is a String.
this code might help u.
|
|
|
|
|
thank you
but this code does not sotore number on edit box as it replace preivious number
i wantr as we use in mobile phone
thank s
Please mail me
|
|
|
|
|
About how many times are you going to ask this question? It's been answered several times.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Here's the code for one more time.
You can call this function whenever the key is pressed and pass an integer to the function underneath based on what button is clicked on the dialog by the user.
m_editCtrl is the control variable for the edit box
In the header file declare the function as
void SetNewText(int p);
void CYourClass::SetNewText(int p)
{
CString s;
m_editCtrl.GetWindowText(s);
CString t;
t.Format ("%d",p);
s+=t;
m_editCtrl.SetWindowText (s);
}
Now to use the function simply do
SetNewText(1); //if the user has clicked 1 and so on
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
-- modified at 9:27 Friday 7th July, 2006
|
|
|
|
|
yogendra kaushik wrote: I want as in phone system when we press buttons they appear on screen
and when dial button is pressed phone dials.
try this :- http://www.codersource.net/mfc_array_controls.aspx
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Hi All,
I am using SetTimer API to create timers in a UI Thread (CWinThread
derived class)
The code looks as follows ->
m_timerId=::SetTimer(NULL,0,1000,NULL);
where m_timerId is a member data variable.
My Message map & onTimer looks as follows.
BEGIN_MESSAGE_MAP(CMyThread, CWinThread) <br />
ON_THREAD_MESSAGE(WM_TIMER, OnTimer) <br />
END_MESSAGE_MAP() <br />
<br />
<br />
void CMyThread::OnTimer(WPARAM wParam, LPARAM ) <br />
{ <br />
if(wParam==m_timerId) <br />
{ <br />
<br />
<br />
<br />
} <br />
}
This code works!!!!!!!!!!!!!!!!
But SetTimer API documentation does not talk about the above usage.
(where in both hWnd and callback functions are NULL)
Has any one tried this kind of usage of SetTimer with CWinThread
object?
If yes, do let me know if you have encountered any problems.
Regards
PS : Most of the documentations talk only about SetTimer working with
either window object or a call back but never with CWinThread!!!. I
have also seen complicated work arounds to make SetTimer work with
CWinThread. So I am little concerned to use this approach.
|
|
|
|
|
kumar_subrahmanya wrote: But SetTimer API documentation does not talk about the above usage.
(where in both hWnd and callback functions are NULL)
Are you sure? Per MSDN:
hWnd
If this parameter is NULL, no window is associated with the timer and the nIDEvent parameter is ignored.
lpTimerFunc
If lpTimerFunc is NULL, the system posts a WM_TIMER message to the application queue.
Either can be NULL independent of the other.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Well, MSDN says "If lpTimerFunc is NULL, the system posts a WM_TIMER message to the application queue." What is application Queue? is it the message queue of the thread which started the timer or it is "THE" applications main message queue?
Here in my code, I have both hWnd and timer call back as null and I am recieving the WM_TIMER messages at my thread message Queue!!!
|
|
|
|
|
You can use WM_TIMER in CWinThread, but there may be problems.
I just finished a graphics processing application and I was using a timer in a worker thread, to do some minor stuff. Since WM_TIMER is a low priority message... during image processing and fast image Blting... the timer was not working correctly... some long delays at random intervals.
My research showed me that it was being caused by rapid WM_PAINT messages due to my flicker-free paint functions. For example, if the user grabbed a large image (several megabytes)on the screen and moved it around with the mouse... the WM_TIMER messages never reached the thread.
I redesigned my worker threads so they work in an infinite loop, with a custom sleep function. The starting and stopping of the threads are purely message based, works *much* better this way.
Note: this may or may not apply to your project.
You can read more about the problem on google:
http://www.google.com/search?hl=en&q=WM_TIMER+low+priority[^]
|
|
|
|
|
Hi thanks for the input. I will check how this would affect my project.
thanks again.
|
|
|
|
|
hi,
I need to create a delay in step of 250 micro sec..But GetTickCount API counts the tick in terms of milli seconds.
Is there any other method to achieve the same using inline assembly, but only issue is it shouldn't be processor specific/dependent...
can someone post a snippet for the same..
thanx..
|
|
|
|
|
|
Hi,
I don't think you will be able to do this in Windows. This is because the Windows timers don't really provide such high resolution. With multimedia timers you can get about 1ms resolution, at best. Check out the timeBeginPeriod function.
If you are into developing hardware you might solve your problem by developing a microcontroller to connect to a serial port, and then user the received serial data as event triggers. With a serial data rate of 128000 bps and 10 bits per byte, you would get about 12800 bytes per second (78 us per byte). Nevertheless, no real guarantees of accurate timming exist, because Windows could always group several bytes together before generating an event to the application, especially if there are other processes running. (you could try a loopback serial cable to avoid developing hardware).
What you could do, using assembly language or C, is to take advantage of the fairly predictable execution rate of processors (after the startup stabilization and cache warming up) to estimate how many instructions execute within a given timer tick interval. For example, if 10ms elapse between timer ticks, and during that time your processor executes 3,000,000 for() loops, then it is a reasonable approximation to consider that your processor will execute 300,000 instruction in 1 ms, or 75,000 in 250 us. So, to wait 250 us you would do "for(int i=0; i<75000; i++);". For this to be accurate your program should not be interrupted by other processes in the system (so it should have a high execution priority), and the for() loops you use to measure execution rate should be very similar (ideally the same) as the for() loops used for waiting. And, of course, the execution time wasted between waits should be negligeble.
One thing you must take into account when writting delays with this technique, is that the execution speed should be measured for each processor, or, ideally, before any execution. For the loops to be similar you could start a loop that you know will take about 1s or so to execute, and when it finished measure the time diference. For example:
void main(void) {
double t0, t1;
t0=((double)clock())/((double)CLOCKS_PER_SEC);
for(int i=0; i<500000000; i++);
t1=((double)clock())/((double)CLOCKS_PER_SEC);
printf("t1-t0=%g", t1-t0);
}
On my computer, which is a Pentium 4 running at 3.2 GHz, this 500,000,000 count loop takes about 1.1 seconds. If I run this application on my old 386 at 25 MHz I could expect it to take over 2 minutes, which could be unacceptable. If your application is to be run on such different machines you should consider first estimating the execution rate by using an alogorithm like:
1) Estimate how many loops can be executed in 0.5 seconds by using a while() loop that keeps running while the timer is under 0.5 seconds, while incrementing the loop counter.
2) Execute the real measurement for() loop using the estimated value in 1), corrected to execute in the time you think is acceptable, while measuring the start time and the end time. For example, if you think users accept waiting for 2 seconds while the application measures execution speed, then the real for() loop should run for a corrected value of about 3 times that achieved in the while loop (step 1) took 0.5 seconds, so step 2) should take no more than 1.5 seconds, or 3 times the time of setp1) ).
Since the loops are diferent, you should expect that a for() loop counting to a value 3 times higher than that achieved with the while() loop does not take 3 times as much time. But, since you measure the actual time of the for loop, that will not be very important for the accuracy of the measure.
For accuracy, the measurement loop should take enough time for the timer tick interval to be negligeable. For example, in Windows XP you get about 100 ticks per second, so measuring for 1 second gives you an error with an order of magnitude of about 1%. Executing measurements for 2 seconds 0.5%, and so on. The worst Windows timer resolution I know is with 95/98 with tick intervals of about 50 ms.
Also take into account that for the loops to be equal, the measure loop and the wait loop should use the same termination conditions. Either both use constant fixed limits, or both use variable limits, otherwise the compiler may generate different code for them. For the same reason, both should be subject to the same compiler optimizations. For best accuracy, try to isolate the loop in a function of its own.
An application built in this manner is not very user friendly, because it will be taking all the available CPU while waiting. This is especially noticeable if the process priority is high. With enough bad programming you can even make the CPU so busy with your loops that not even the mouse pointer gets any CPU to move around.
Rilhas
|
|
|
|
|
hi
i hav a listbox in dialog.
i have to add two column in the list.
in the leftone i want to add image & in the second column i want to string.
and the other thing is that i ahev to add these data from a loop.
plz tell me
thanx
|
|
|
|