|
Not moving the controls in the good position.
I dont know how to use this function.
Maybe on this way:
void CEjemplo::OnSize(UINT nType, int cx, int cy)
{
CDialogEx::OnSize(nType, cx, cy);
CRect myRect;
GetClientRect(&myRect);
if (GetDlgItem(IDC_EDIT1))
{
m_Edit.MoveWindow(5,5,cx-55,cy-55);
m_Button1.MoveWindow(myRect.right, myRect.bottom,
myRect.Width(), myRect.Height());
}
}
But I dont want to change the size, only the position. I'd like to move at the right botton corner.
|
|
|
|
|
use SetWindowPos (with the SWP_NOSIZE option, check the documentation ) function instead of MoveWindow.
M.
Watched code never compiles.
|
|
|
|
|
I've tried with this:
void CEjemplo::OnSize(UINT nType, int cx, int cy)
{
CDialogEx::OnSize(nType, cx, cy);
CRect myRect;
const CWnd &p=wndBottom;
GetClientRect(&myRect);
if (GetDlgItem(IDC_EDIT1))
{
GetDlgItem(IDC_EDIT1)->MoveWindow(5,5,cx-50,cy-80);
m_Button1.SetWindowPos(&p,5,5,cx-50,cy-75,SWP_NOSIZE);
}
}
But when I run the application it crash
|
|
|
|
|
antonio343 wrote: But when I run the application it crash
Exception thrown? Assertion fired? Have you stepped into the code to see what is actually going on?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
I'm sorry , the error wasn't due to the setwindowspos. I solved the error.
It run well, but I need know the coordinates of the right bottom corner.
|
|
|
|
|
antonio343 wrote: It run well, but I need know the coordinates of the right bottom corner.
Relative to what?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
antonio343 wrote:
m_Button1.SetWindowPos(&p,5,5,cx-50,cy-75,SWP_NOSIZE) change this to read:
m_Button1.SetWindowPos(&wndTop, cx - m_Button1.Width - 5, cy - m_Button1.Height - 5, 0, 0, SWP_NOSIZE);
If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun
|
|
|
|
|
I cant change this, becouse CButton don't have some member "width" and "Height"
|
|
|
|
|
A CButton is a Window, WIndows have Rect (GetWindowRect() function). Rect gives you height and width. So it's not a straightforward as posted but easily obtainable.
|
|
|
|
|
Sorry, the other poster is right. Use
CRect rect;
m_Button1.GetWindowRect(&rect)
rect.Width()
rect.Height()
If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun
|
|
|
|
|
Assuming the coordinate system is correct (Client View, Control View, Screen View), which is a big assumption at this point, the line
m_Button1.MoveWindow(myRect.right, myRect.bottom, seems to want to put the left edge of the button at the right edge of the main window, therefore, it's not visible since it's off the right side of the main window. Similarly for the y coordinate, you're putting the top of the button starting at the bottom of the window, therefore it's outside the viewing area
|
|
|
|
|
antonio343 wrote: Now, when I maximized the dialog the button dont move itself...
See if the Extras section of this article is of any help. I've updated the code in a newer project but the premise is the same.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
+5. Good bit of code.
If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun
|
|
|
|
|
The first two arguments to MoveWindow are the new X and Y coordinates of the upper left of the window. You are putting all your things at [5,5], on top of one another. No wonder it doesn't seem to work.
|
|
|
|
|
|
Hi,
I have a piece code which I wrote several years ago. This code was written on a XP system with VS2005.
The code worked fine and in fact the existing .exe still works fine on some machines.
Now, this code seems to work on some machines and not on others. I suspect the difference between target machines in 32 or 64 bit, though that may be totally wrong... The development machien is 32 bit XP machine and the machine on which it fails is a Windows 2008 Server R2 64-Bit.
The code will still CoInitialize's and connects just fine and the 'logging in' also works.. Its the call to:
hresult = ptrRS.CreateInstance(__uuidof(Recordset)); // E_NOINTERFACE error
which fails.
This is a snippet of the code:
#include "stdafx.h"
#include <string>
using namespace std;
#include "dbAccess.h"
#include "XYTrace.h"
#pragma comment(lib,"trace.lib")
#include "ATLComTime.h"
#include <comdef.h>
#include "Afxdisp.h"
#include <ole2.h>
#import "C:\Program Files\Common Files\System\ADO\msado15.dll" rename("EOF", "ADOEOF") rename("Property", "PProperty")
_WebRes *wr;
HRESULT hresult;
using namespace ADODB;
_RecordsetPtr ptrRS;
.....
.....
.....
bool ibsConnect(char *userid, char *iniPath)
{
CLSID clsid;
hresult = CoInitialize(NULL);
WriteTrace(TraceXDetail, "CoInitialize returned %x", hresult);
if(FAILED(hresult)) {
WriteTrace(TraceError, "**** CoInitialize Failed ");
return false;
}
hresult=CLSIDFromProgID(OLESTR("TTExt.WebRes"), &clsid);
WriteTrace(TraceXDetail, "CLSIDFromProgID returned %x", hresult);
if(FAILED(hresult))
{
switch (hresult) {
case CO_E_CLASSSTRING:
WriteTrace(TraceError, "**** CLSID Failed -- registered CLSID for the ProgID is invalid");
return false;
break;
case REGDB_E_WRITEREGDB:
WriteTrace(TraceError, "**** CLSID Failed -- error occurred writing the CLSID to the registry.");
return false;
break;
default:
WriteTrace(TraceError, "**** CLSID Failed -- unknown reason");
return false;
break;
}
}
hresult=CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, __uuidof(_WebRes), (LPVOID *)&wr);
WriteTrace(TraceXDetail, "CoCreateInstance returned %x", hresult);
if(FAILED(hresult))
{
switch (hresult) {
case REGDB_E_CLASSNOTREG:
WriteTrace(TraceError, "**** CoCreateInstance Failed -- Class not registered");
return false;
break;
case CLASS_E_NOAGGREGATION:
WriteTrace(TraceError, "**** CoCreateInstance Failed -- class cannot be created as part of an aggregate.");
return false;
break;
case E_NOINTERFACE:
WriteTrace(TraceError, "**** CoCreateInstance Failed -- class does not implement the requested interface");
return false;
break;
case E_POINTER:
WriteTrace(TraceError, "**** CoCreateInstance Failed -- ppv parameter is NULL");
return false;
break;
case 0x8007007e:
WriteTrace(TraceError, "**** CoCreateInstance Failed -- the specified module could not be found");
return false;
default:
WriteTrace(TraceError, "**** CoCreateInstance Failed -- unknown reason - hresult |%x|", hresult);
return false;
break;
}
return true;
}
BSTR bstrMess = NULL;
char cStr[256];
strcpy(cStr, "OK");
bstrMess = A2BSTR(cStr);
strcpy(iniPath, "");
WriteTrace(TraceInfo, "Connecting to IBS database with userid '%s' and ini path '%s'", userid, iniPath);
# ifdef gt_DLL7302
if (!wr->Connect(LPCSTR(userid), LPCSTR(iniPath), &bstrMess)) {
# else
if (!wr->Connect(LPCSTR(userid), "")) {
# endif
WriteTrace(TraceError, "**** TTExt Connect Failed");
USES_CONVERSION;
strcpy(errorMess, (W2A(bstrMess)));
WriteTrace(TraceError, "CONNECT: return message - '%s'", errorMess);
SysFreeString(bstrMess);
return false;
}
WriteTrace(TraceXDetail, "CONNECT: returned");
USES_CONVERSION;
strcpy(errorMess, (W2A(bstrMess)));
WriteTrace(TraceXDetail, "CONNECT: return message - '%s'", errorMess);
SysFreeString(bstrMess);
if (!wr->SetUser(LPCSTR(userid))) {
WriteTrace(TraceError, "**** TTExt SetUser Failed");
return false;
}
WriteTrace(TraceXDetail, "IBS TTExt SetUser succeeded with userid='%s'", userid);
hresult = ptrRS.CreateInstance(__uuidof(Recordset));
if(FAILED(hresult)) {
WriteTrace(TraceError, "**** ptrRS.CreateInstance Recordset Failed '%x'", hresult);
return false;
}
return true;
}
......
......
17:45:59_472_D20: Starting GEX Server (Version 1.9.13)
17:45:59_472_D20: for ttext.dll Version (DLL 7303)
17:45:59_472_D20: Application name gexServer
17:45:59_472_D20: Parameter: Server listening port:'999'
17:45:59_472_D20: Parameter: Server trace option: 'trace'
17:45:59_492_D20: CoInitialize returned 0
17:45:59_492_D20: CLSIDFromProgID returned 0
17:45:59_502_D20: CoCreateInstance returned 0
17:45:59_502_D20: Connecting to IBS database with userid 'GEX' and ini path ''
17:46:00_013_D20: CONNECT: returned
17:46:00_013_D20: CONNECT: return message - 'OK'
17:46:00_013_D20: IBS TTExt SetUser succeeded with userid='GEX'
17:46:00_013_D20: **** ptrRS.CreateInstance Recordset Failed '80004002'
17:46:00_013_D20: **** IBS Server connect Failed -- exiting
17:46:00_013_D20: Exiting GEX Server
CLSIDS: Development:
Name: WebRes
GUID: {02CB0046-BA2E-4BA5-B001-BAE2767188A5}
--------------------------------------------------------------------------------
Interface
{02CB0046-BA2E-4BA5-B001-BAE2767188A5} = WebRes
ProxyStubClsid = {00020424-0000-0000-C000-000000000046}
ProxyStubClsid32 = {00020424-0000-0000-C000-000000000046}
TypeLib = {66CB7502-6F39-4558-8B26-D6BDB18910AA}
TypeLib[Version] = 1.0
CLSID
{00020424-0000-0000-C000-000000000046} = PSOAInterface
InprocServer = ole2disp.dll
InprocServer32 = oleaut32.dll
InprocServer32[ThreadingModel] = Both
TypeLib
{66CB7502-6F39-4558-8B26-D6BDB18910AA} =
1.0 = TTExt
0 =
win32 = c:\shared\dll7303\ttext.dll
FLAGS = 0
HELPDIR = c:\shared\dll7303
The following are the CLSID's from my development machine, a target machine where it does work and a target machine where it does not work.
CLSIDS: Working:
Name: WebRes
GUID: {02CB0046-BA2E-4BA5-B001-BAE2767188A5}
--------------------------------------------------------------------------------
Interface
{02CB0046-BA2E-4BA5-B001-BAE2767188A5} = WebRes
ProxyStubClsid = {00020424-0000-0000-C000-000000000046}
ProxyStubClsid32 = {00020424-0000-0000-C000-000000000046}
TypeLib = {66CB7502-6F39-4558-8B26-D6BDB18910AA}
TypeLib[Version] = 1.0
CLSID
{00020424-0000-0000-C000-000000000046} = PSOAInterface
{00020424-0000-0000-C000-000000000046}[PSOAInterface] =
InprocServer = ole2disp.dll
InprocServer[ole2disp.dll] =
InprocServer32 = oleaut32.dll
InprocServer32[ThreadingModel] = Both
InprocServer32[InprocServer32] = cQb2bTV?j9JZ]N4eNMNY>M5KDYSUnf(HA*L[xeX)y
InprocServer32[oleaut32.dll] =
TypeLib
{66CB7502-6F39-4558-8B26-D6BDB18910AA} =
1.0 = TTExt
0 =
win32 = E:\ibs_fdrv\ibs\TeeTimes\TTExt.dll
FLAGS = 0
HELPDIR = E:\ibs_fdrv\ibs\TeeTimes
CLSIDS: Failing:
Name: WebRes
GUID: {02CB0046-BA2E-4BA5-B001-BAE2767188A5}
--------------------------------------------------------------------------------
Interface
{02CB0046-BA2E-4BA5-B001-BAE2767188A5} = WebRes
ProxyStubClsid = {00020424-0000-0000-C000-000000000046}
ProxyStubClsid32 = {00020424-0000-0000-C000-000000000046}
TypeLib = {66CB7502-6F39-4558-8B26-D6BDB18910AA}
TypeLib[Version] = 1.0
CLSID
{00020424-0000-0000-C000-000000000046} = PSOAInterface
InprocServer32 = C:\Windows\system32\oleaut32.dll
InprocServer32[ThreadingModel] = Both
TypeLib
{66CB7502-6F39-4558-8B26-D6BDB18910AA} =
1.0 = TTExt
0 =
win32 = D:\IBS\ibsconsole\ttext.dll
FLAGS = 0
HELPDIR = D:\IBS\ibsconsole
Thanks for all help in advance
Phil
|
|
|
|
|
Hi!
I have don this thing before using VC++ and MFC. But my new owner don't want to use VC++. So I decided to port the whole thing to Win API. Generally this should be easy, but I have problems with the DLL part somehow.
When I make a basic DLL with only the dll_process_attach and just the initalization and some mouse handling, the DLL works! But when it's got basic TLS code to save my custom control class address for multithreadding support, it just don't work. The test app isn't start at all - and it isn't shows up in the TaskManager. AND where I got confused. If I comment all the added lines it still not change a thing. Even if I clear all generated files and recompile.
Did someone do this before? Dose anyone have a template to this? I confused because I did done it in VC++ and it's working.
Please help! Thx!
|
|
|
|
|
Ok! The basic problem is solved. I have forgotten to change the class name in the resource.
Btw the TSL thing isn't working how it's presented in the Win API programming help file. So if someone has working solution for DLL with TSL - or a way to store an address of the class for every thread - I need it badly!
Realy, I don't know if I need to do this TSL thing for running different instances of a control, but if not, then how to store the class's address?
Thx for any help!
|
|
|
|
|
Hello Friends
I am creating a map of key as string and data is of One class Object reference.
As i am inserting data into map as i am getting new string,so before loading new object I am deleting last object.but As i delete object,It is clearing from map also.
Here is the sample of code
class Test
{
int a;
int b;
}
map<string,Test*> mapTest;
As I run a loop of my some condition
On adding every new string that is some file name i am reading file values into that class.
Test* obj = new Test();
for(.......)
{
...
...
reading File int obj pointer
And then inserting into map
mapTest.insert(make_pair(string,objTest));
}
delete obj;
obj=NULL;
Any Suggestions.
Thanks & Regards
Yogesh
|
|
|
|
|
yogeshs wrote:
Any Suggestions.
Don't delete it.
|
|
|
|
|
But If i dont delete then it is eating my memory.
As i my Class Size is too Long bcoz I am using for reading a file.
Regards
Yogesh
|
|
|
|
|
yogeshs wrote: But If i dont delete then it is eating my memory.
Well, how exactly do you expect to process the information in your objects if they are not in memory? If your application is memory constrained then you need to reduce the requirements by reading and processing your file one record at a time.
|
|
|
|
|
Hello,I agree with you that for memory constraint i need to create one object and processing should be done.I was doing this previously.
But my requirements are changed i need to keep in memry until application doesnt close.So that if user chooses same file I dont need to read it again.
This is the scenario.
Any Ideas.
Thanks & regards
yogesh
|
|
|
|
|
Think about this logically: you need all the records from the file in memory at the same time, so the laws of physics state that you will consume record_count x record_size bytes of memory at minimum. The only alternative is what I suggested earlier, read in only the records you need at any one time. The overhead to do this is unlikely to be great enough to cause you any major problems.
|
|
|
|
|
Hello
I am totally agree with you Mr. macCutchan.
And we were doing like that but now Requirements are changed.
Regards
Yogesh
|
|
|
|
|