|
If you don't have the lib file as Zac suggested, check out the IMPLIB.exe and IMPDEF.exe utilities.
They can generate the files you need to link.
Mark
|
|
|
|
|
dear sir;
I am using visual c++.
When I print on laserjet, papers skip well but on dot matrix even if I setup well the lengh of paper; papers are not skipped well. What to do
|
|
|
|
|
what exactly do you mean by "skipped papers"?
|
|
|
|
|
paper cannot jump from one to another page of the continous paper
|
|
|
|
|
I am getting this error message when I am trying to create a Dialog Procedure and make it member of a class so I can use ‘this’ pointer of that class.
“error C2440: 'type cast' : cannot convert from 'overloaded-function' to 'DLGPROC'”
Please help me to solve this problem. Thanks in advance.
Priyank
|
|
|
|
|
Are you using MFC?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
|
Normally you cannot do this. The easiest way is to declare the DlgProc as a static member, but that will give you problems accessing other class members. You can also store the this pointer in a static member, and again add a static DlgProc then cast the pointer to access the class members, but this method causes problems when using more than one instance of the class. By far, the best method is to use a thunk.
|
|
|
|
|
I believe you are trying to make a wrapper class for handling dialog without using MFC ? If this is the case, there is a trick to do that. If not, then ignore my post
Ok, so member functions and global functions don't have the same parameters (the this parameter is passed to a member function). That's why you are getting this error. However there is a trick to do what you are looking for. I'm a little bit lazy to explain all in detail so I made a search on google, and I found this[^] piece of code that solve your problem. If you don't understand some parts, just ask.
Basically the idea is that you save the pointer to your class instance with SetWindowLong as user data and you get it back in your dialog procedure, so that you can cast it back to your class (and so, call a member function that will manage the messages).
Hope this helps
|
|
|
|
|
Thanks for your reply,
I tried that code. But now I get another error. "error C3861: 'Dialog': identifier not found, even with argument-dependent lookup" at at line "Dialog* pthis = (Dialog *)GetWindowLong( hWnd, GWL_USERDATA );"
maybe because that code is in MFC while I am using win32. Can I know how can I use the same with win32?
Priyank
|
|
|
|
|
Of course, I gave you the link so you have an example to understand how it work. If you copy paste it, it's normal that it won't work .
Dialog is the name of the class they use. Replace it by the name of your class (and isntead of copy/pasting the code, try to understand it, it is much more useful).
priyank_ldce wrote: maybe because that code is in MFC while I am using win32
Not at all, this code is pure Win32.
|
|
|
|
|
Oh sorry, Dialog is looking more like windows class or variable type not user class and I didn't check it. But it is working now . Thanks again.
Priyank
|
|
|
|
|
When using that method make sure that you only create one instance of the class. Because the this pointer is stored in a static member, all class instances will share the same value of that pointer. When dereferencing that pointer in your DlgProc, it will always be the same. I'm guessing that your code only needs one instance, but keep this in mind next time you try using this method (ie for a TimerProc).
|
|
|
|
|
Did you look at the link ??
It has nothing to do with storing the pointer as a static member. It stores the pointer using SetWindowLong and associate it with a windows handle. Thus, each time you have a new instance of your dialog, you also have another windows handle. So, you can perfectly have several instances of this class without any problem.
|
|
|
|
|
I do appologise, I had a quick glance at the article, perhaps a little too quick, and incorrectly thought it was an implementation of another method.
|
|
|
|
|
I know I should know the answer to this...
I want to round a number *down* to an integer multiple of another number.
% doesn't work on doubles / floats.
fmod does, but it has the same problem.
Using % or fmod, I can round a number towards 0. I want to round it towards negative infinity.
So,
rounddown(82,40) becomes 80.
rounddown(0,40) becomes 0;
rounddown(-39,40) becomes 0 as well, but I want -40!
I hope that explains things well enough.
Yours in need-of-more-caffeine-or-the-weekend,
Iain.
|
|
|
|
|
Mmmhh, maybe using floor()[^] ? You could divide the first number by the second (82/40=2.05 and -39/40=-0.975), then use floor, that will give you 2 and -1 (respectively) and finally multiply back by your second number: 2*40=80 and -1*40=40.
Hope this helps
|
|
|
|
|
#define ROUNDDOWN(number,base) ( base * floor (double(number) / double(base)) )
does the job perfectly, thanks Cedric. I didn't have the double()s in to start with, and I did get odd results when using integers....
Iain.
|
|
|
|
|
If you know that your first number was negative, and you actually rounded up, then just substract the second number from the result and you have rounded down.
Hope that helps.
|
|
|
|
|
My initial version did have (number < ) ? (....) : (...), but my adding / subtracting numbers messed it up further when I was on a number "boundary".
Cedric (38mins ago) gave me the clue (ie 99% of the work) I needed.
Thanks,
Iain.
|
|
|
|
|
I have created somewhat of a window wrapper class in non MFC. Within this class I have added the ablity for a user to attach their own window procedure. So basically I am dealing with two procedures. That of the class will either call the new attached procedure or call DefWindowProc(). This itself is not the problem. The problem is which messages should be handled within the class, which should be passed to the new procedure (bearing in mind the new procedure will call DefWindowProc). I read somewhere about a few messages that MUST be handled though now I am unable to find which messages, so could somebody please jog my memory.
|
|
|
|
|
nothing is so clear anywhere
it is recommended to call DefWindowProc after every
message you handle. But some times it is not a good idea.
suppose we want to override the look of a control in this case if we update the look ourself and then call DefWindowProc it will overwrite over operation.
so calling the default here not a good idea.
just remember that window functionality must not suffer.
otherwise Windows will get angry.
|
|
|
|
|
Hi.
I'm writing an application that it connects with a SQL database using ADO, and in many places it execute store procedures, but there is a routine that it doesn't work. This is the portion of code with the bug.
<br />
<br />
...<br />
Cmd->PutRefActiveConnection(pAdoCone);<br />
<br />
Cmd->CommandText = "ProductsInOrders";<br />
Cmd->CommandType = adCmdStoredProc;<br />
<br />
vtidProduct.vt = VT_I4;<br />
vtidProduct.intVal = (int)idProduct; <br />
<br />
paramID = Cmd->CreateParameter ("ProdID",adInteger,adParamInput,sizeof(int),vtidProduct);<br />
<br />
paramID->Value = vtidProduct;<br />
<br />
Cmd->Parameters->Append(paramID);<br />
<br />
Rs = Cmd->Execute(&vtMissing, &vtMissing, adCmdStoredProc); <br />
<br />
m_lstOrders.ResetContent();<br />
<br />
while (!Rs->adoEOF)<br />
{<br />
idOrder = Rs->GetFields()->GetItem("OrderID")->Value.iVal;<br />
<br />
data.Empty();<br />
<br />
data.Format("%i", idOrden); <br />
<br />
m_lstOrders.AddString (data);<br />
<br />
<br />
Rs->MoveNext(); <br />
}<br />
...<br />
Well, it looks like the store procedure return 0 records, that's why the flow never enter the while, but I test the SP in SQL, (SQL 2000), and it works, and there is more, I wrote a little VB 6.0 application to test the SP and it works too!!. So, there's something wrong, (maybe is something stupid but I can't see it now, I'm blind!). Debugging, I can see right values for the parameter idProduct, I think the Execute method is wrong, because everything goes well until that line, then I get an empty recordset.
If someone see what is wrong, I will really appreciate any suggestion.
Thanks.
Demian.
"I have always wished that my computer would be as easy to use as my
telephone. My wish has come true. I no longer know how to use my telephone."
-Bjarne Stroustrup, computer science professor, designer of C++
programming language (1950- )
|
|
|
|
|
Hi,
I hawe a problem writing registry keys and values in registry under current user that has not administrator rights. We have an application that must work under common user priveleges but must install it under adin rights because we must register some activeX components. Is there a Way to write registry entries from one user to another. In some instalations I saw some options that say "use settings for all users"... if those settings are writen in the registry how can I access them and where are they stored.
I'm working in VS.NET 2002 in MFC.
Thanks in advance.
|
|
|
|
|
Just doing a quick peek, and you could use LogonUser , ImpersonateLoggedOnUser , etc.
Or CreateProcessWithLogonW...
You'd need the adminish name & password. But unless you knew them, you shouldn't be fiddling with HKLM anyway. That's the whole point of user security...
Iain.
|
|
|
|