|
Dear all,
I writting an application using MFC.
Now I need to access to the View object from the App class.
Could you please tell me how.
Thanks a lot in advance.
-Kien Bui
|
|
|
|
|
In SDI app: ((CFrameWnd*)AfxGetMainWnd())->GetActiveView()
In MDI app: ((CMDIFrameWnd*)AfxGetMainWnd())->GetActiveFrame()->GetActiveView()
Robert-Antonio
"Love without sex is like a fish without antlers"
|
|
|
|
|
Thank you very much!
-Kien Bui
|
|
|
|
|
How to get 'IRowsetFind' interface in oledb sdk !
dear all:
i will use following code in my program(C++) :
discover 'pICommandProperties->SetProperties(1,rgInitPropSet);' return failed code 'DB_S_ERRORSOCCURRED'
so 'pIRowset->QueryInterface(IID_IRowsetFind,(void **)&pIRowsetFind);' return failed!
dear all, please help me! how to get 'IRowsetFind' interface in oledb sdk , and how to use 'IRowsetFind->FindNextRow()'
InitProperties[0].dwPropertyID=DBPROP_IRowsetScroll;
InitProperties[0].dwOptions=DBPROPOPTIONS_REQUIRED;
InitProperties[0].dwStatus=DBPROPSTATUS_OK;
InitProperties[0].colid=DB_NULLID;
InitProperties[0].vValue.vt=VT_BOOL;
InitProperties[0].vValue.lVal=VARIANT_TRUE;
InitProperties[1].dwPropertyID=DBPROP_IRowsetFind;
InitProperties[1].dwOptions=DBPROPOPTIONS_REQUIRED;
InitProperties[1].dwStatus=DBPROPSTATUS_OK;
InitProperties[1].colid=DB_NULLID;
InitProperties[1].vValue.vt=VT_BOOL;
InitProperties[1].vValue.lVal=VARIANT_TRUE;
rgInitPropSet[0].cProperties=2;
rgInitPropSet[0].guidPropertySet=DBPROPSET_ROWSET;
rgInitPropSet[0].rgProperties=InitProperties;
hr=pICommandText->QueryInterface(IID_ICommandProperties,(void **)&pICommandProperties);
hr=pICommandProperties->SetProperties(1,rgInitPropSet);
if (DB_S_ERRORSOCCURRED==pICommandProperties->SetProperties(1,rgInitPropSet))
cout<< "test";
if(FAILED(hr))
{
cout<< "OLEDB Error !\r\nExecute Failed To Set Rowset Properties";
}
hr = pIRowset->QueryInterface(IID_IRowsetFind,(void **)&pIRowsetFind);
if(FAILED(hr))
{
cout << "Failed to get IID_IRowsetFind interface.\n";
cout << endl;
} //end if
Laker
|
|
|
|
|
Hi guys
I'm having troubles with resources in w98 and one of the questions is the following.
I'm using a resource meter to know the GDI resources available, and when I open a CDialog with a lot of controls (>100), the resources go down and when I close it the resources don't raise again until I close the app.
Is this normal? If not, what can be the cause?
I'm using a lot of CLabel controls (derivesd from CStatic controls classes get it here in codeproject)
Best Regards
Doc
|
|
|
|
|
No, it's a memory leak. Some of your controls are creating resources and not cleaning them up. From the sound of it, probably fonts.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Without using MFC how can I tell if the mouse is over my buttons?
I've tried WM_NCHITTEST and WM_MOUSEMOVE along with stuff like ScreenToClient, GetDlgItem, GetDlgCtrlID, ChildWindowFromPoint, ect, but nothing seems to be working.
Any Ideas? Some code would help me out, thanks.
wWw.KruncherInc.cOm - My cool programs
|
|
|
|
|
Just do subclassing for CBUtton
e.g
CYourButton : public CButton
{
.
.
};
and AAdd message Handlers
ON_mouse_Move
regards
Balkrishna Talele
|
|
|
|
|
Can't do that, I'm using pure WIN32 API, no MFC (if I wanted something like MFC I would use VB).
wWw.KruncherInc.cOm - My cool programs
|
|
|
|
|
may i know , what are you using. is it SDK , and if so you might have register the class, in WinProc you will receive all the messages
|
|
|
|
|
You do not need MFC to subclass button controls. You write your button's window procedure and use SetWindowLong() with the GWL_WNDPROC index to subclass the button.
LRESULT CALLBACK MyButtonWindowProc(HWND hWnd, UINT nMsg, WPARAM wp, LPARAM lp)
{
switch (nMsg)
{
case WM_MOUSEMOVE:
default:
return DefWindowProc(hWnd, nMsg, wp, lp);
}
return 0;
}
SetWindowLong(ButtonHwnd, GWL_WNDPROC, (LONG)MyButtonWindowProc);
Sonork 100.11743 Chicken Little
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
Within you lies the power for good - Use it!
|
|
|
|
|
GetCursorPos() returns the current position of the mouse. All you need to do is check if it's within the bounds of your button. You can do this in response to a WM_TIMER , but imho it's better to use TrackMouseEvent() . None of this has any dependency on MFC.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Hello,
Does anybody know of a way to automate both opening applications and various application calls (possibly .dll files) in Windows 2000 or XP? For example, I am developing a graphics application in C++. There are various repetetive tasks needed in order to prepare many of the application assets. Also, I wanted to use this program for testing purposes or to automate repetitive tasks for various applications I am using in Windows. Possibly record an action script and then I would be able to play the script at any time to perform the recorded task. This could also be applications that I am developing myself.
Are there any libraries that exist that facilitate this in Windows?
Are there any programs already in existence that are able to perform this task?
Thank You.
|
|
|
|
|
are u lookin for winrunner/loadrunner etc...
It's not a bug, it's an undocumented feature. suhredayan@omniquad.com
messenger :suhredayan@hotmail.com
|
|
|
|
|
Check this for ideas
http://www.codeproject.com/dll/eventrecorder.asp
you can find similar articles by looking for journal + hook
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Does anyone know where to find an md5 encryptor for executables? I need to encrypt an exe with the message digest algorithm.
-Ryan M.
|
|
|
|
|
Try this library.
Robert-Antonio
"Life is very hard, if you apply E-R model to it."
|
|
|
|
|
Is there a way to tell my VC6 project to execute a script (foo.cmd ) before any files are compiled? I tried adding a custom build step (whose dependency is correctly determined), but the step gets invoked after all the source files are compiled.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Add the foo.cmd file to the project and set custom build step only for this file. Custom build steps for specific files are executed before compilation, but custom build step for whole project is executed after compilation and link.
Robert-Antonio
Love, truth and electric traction must gain victory over hate, lie
and diesel traction.
|
|
|
|
|
Robert-Antonio, the next time you're in Boston, I will buy you as many beers as you desire! Many thanks!
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Sounds lovely . What a pity, that Boston is toooo far from Prague...
Robert-Antonio
"I launched Norton Commander and saw, drive C: on the left, drive C: on the right...
Damn, why I need two drives C:??? So I formatted one..."
|
|
|
|
|
Hey, for that kind of offer, the trip seems worth it...
Steve S
|
|
|
|
|
ok, so i got a book on C++, cuz i figure that i need to learn a new lang. VB is ok, but i want to learn new stuff..
anyway, i think this book is for c++6, and i got c++.net2k3
so i am writing the first couple of lessons, basic io stuff, and it doesn't work like its supposed to. lemme show ya:
------------------------------------------
<br />
<br />
#include <iostream> <br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
main (void) <br />
{ <br />
iostream::cout << "What is your age?" << endl; <br />
iostream::cin >> Age >> endl; <br />
iostream::cout << "What is your Character Type?" << endl; <br />
iostream::cin >> CharacterType >> endl; <br />
iostream::cout << "What is your character's description?" << endl; <br />
iostream::cin >> CharacterDescription >> endl; <br />
<br />
iostream::cout << "Your character's age is " << Age << " , character type is " << CharacterType << " , and your character's description is " << CharacterDescription << " <br />
<br />
return 0; <br />
} <br />
-------------------------------------------
so then when i run it, and it asks my age, and i put in 28, it assigns 2 to Age, 8 to CharacterType, and looks like this <its in="" dos="" console="" mode,="" i've="" tried="" both="" win32="" app,="" and="" .net="" app="">:
----------------------------
What is your age? 28
What is your Character Type? What is your Character's Description? Blue
Your character's age is 2 , character type is 8 , and your character's description is b
----------------------------
i did everything just as it is in the book, and when i look at the variables, they say they are supposed to handle more than just one character, but the prog is only taking the one character.
What the...?? <shakes head=""> can some c++.net guru gimme a little help here?
thanks.
Just one a few seconds more, that's all I need. Close a door here, open a new one there, slip a bit of code off to the side to confuse the trail. The logout port is ahead... --«§øùl Ëס§†ëñçê»
|
|
|
|
|
SoulExistence wrote:
main (void)
This is C. I believe that you get the int return type by default, but it should look like this:
int main()
SoulExistence wrote:
iostream::cout
This is bizarre. You need to #include iostream (is that what you did above), and NOT iostream.h ( I can't tell, you didn't check 'don't treat <'s as HTML tags ). Then cout and cin are in namespace std. There is no namespace iostream. Put using std::cout at the top, and then you can just use cout with no namespace qualification. You also need to put a using for std::cin and std::endl.
SoulExistence wrote:
anyway, i think this book is for c++6, and i got c++.net2k3
That only means that if any code in the book does not compile, it is not correct C++. You have the better compiler, but it's unlikely that you'll find any differences for some time.
SoulExistence wrote:
but the prog is only taking the one character.
SoulExistence wrote:
char CharacterType
A char is one character. A string is more than one. And to use strings you need to #include <string>
and put using std::string at the top. The extra include you mentioned was almost certainly stdafx.h, this include MUST be before all the others, but you can ( and I do ) put your standard library #includes and using std::whatever stuff in stdafx.h, so it's visible everywhere.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
/* there's some other include that .net puts in there that i don't know what its for, but its a #include "stdafx.h" */
#include <iostream>
#include <string>
using std::cout;
using std::cin;
using std::endl;
using std::string;
// global variables are evil, although they are forgivable at this stage of learning, remember that variables belong in classes.
int Age, Type;
string Description;
/*the variables byte Age, char CharacterType, and string CharacterDescription are set up here */
int main ()
{
cout << "What is your age?" << endl;
cin >> Age; // Putting endl here is ridiculous
cout << "What is your Character Type?" << endl;
cin >> Type;
cout << "What is your character's description?" << endl;
cin >> Description; // Note that cin will stop on a space. You need to use getline if you want to accept spaces in your string, otherwise "Fred Smith" will only get 'Fred'.
cout << "Your character's age is " << Age << " , character type is " << Type << " , and your character's description is " << Description << endl;
return 0;
}
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|