|
Perhaps your client has dual monitors, and has them set up to act like a single desktop window. That would make the X values double what you might expect while the Y values would be "normal".
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
But wouldn't this would still require one monitor to have an x-axis of (about) 2941?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
To create a secured MS Access database programmatically using MFC I followed the procedure described at http://www.litwindow.com/Knowhow/HowTo/howto_create_secure_access_dat.html[^]. I have incorporated the code in one of my functions. However, while granting privileges to the newly created group exception is thrown and I am not able to create the database. The function in which I am using the code is as below.
void CSecuredAccessDlg::OnBnClickedOk()
{
if(m_fileName.IsEmpty())
{
MessageBox("No file selected!",NULL,MB_ICONERROR);
return;
}
CString strConfig,sSql;
CString strAccessDriver;
CDatabase database;
strAccessDriver="Microsoft Access Driver (*.mdb)";
if(_access("my workgroup.mdw",0)==0)
unlink("my workgroup.mdw");
if(_access(m_fileName,0)==0)
unlink(m_fileName);
strConfig.Format("CREATE_SYSDB=\"my workgroup.mdw\"\0\0");
SQLConfigDataSource(NULL, ODBC_ADD_DSN, strAccessDriver,strConfig);
strConfig.Empty();
strConfig.Format("CREATE_DB=\"%s\"\0\0",m_fileName);
SQLConfigDataSource(NULL, ODBC_ADD_DSN, strAccessDriver,strConfig);
strConfig.Empty();
TRY
{
strConfig.Format("DRIVER={%s};DSN='';READONLY=FALSE;"
"CREATE_DB=\"%s\";DBQ=%s;SystemDB=%s;UID=admin;"
"ExtendedAnsiSQL=1",strAccessDriver,m_fileName,m_fileName,
"my workgroup.mdw");
if(database.OpenEx(strConfig,CDatabase::noOdbcDialog))
{
sSql.Format("CREATE GROUP %s %s","Administrators","1234ABC");
database.ExecuteSQL(sSql);
sSql.Empty();
sSql.Format("CREATE USER %s \"%s\" %s","Pani","","1234DEF");
database.ExecuteSQL(sSql);
sSql.Empty();
sSql.Format("ADD USER %s TO %s","Pani","Administrators");
database.ExecuteSQL(sSql);
sSql.Empty();
sSql.Format("ADD USER %s TO %s","Pani","admins");
database.ExecuteSQL(sSql);
database.Close();
unlink(m_fileName);
strConfig.Empty();
strConfig.Format("CREATE_DB=\"%s\"\0SystemDB=my workgroup.mdw"
"\0UID=Pani\0\0",m_fileName);
SQLConfigDataSource(NULL, ODBC_ADD_DSN, strAccessDriver,strConfig);
strConfig.Format("DRIVER={%s};DSN='';READONLY=FALSE;"
"CREATE_DB=\"%s\";DBQ=%s;SystemDB=%s;UID=Pani;ExtendedAnsiSQL=1",
strAccessDriver,m_fileName,m_fileName,"my workgroup.mdw");
if(database.OpenEx(strConfig))
{
sSql.Format("GRANT ALL PRIVILEGES ON DATABASE TO Administrators");
database.ExecuteSQL(sSql);
sSql.Format("REVOKE ALL PRIVILEGES ON DATABASE FROM admin");
database.ExecuteSQL(sSql);
sSql.Format("REVOKE ALL PRIVILEGES ON DATABASE FROM admins");
database.ExecuteSQL(sSql);
sSql.Format("REVOKE ALL PRIVILEGES ON DATABASE FROM users");
database.ExecuteSQL(sSql);
sSql.Format("ALTER USER Pani PASSWORD %s \"%s\"","pani123","");
database.ExecuteSQL(sSql);
FillData(&database);
database.Close();
}
}
}
CATCH(CDBException, e)
{
if(database.IsOpen())
database.Close();
MessageBox(e->m_strError,NULL,MB_ICONERROR);
return;
}
END_CATCH
}
Can anyone provide suggestions for correcting the code?
Thanks in advance.
Pani68
modified on Thursday, April 2, 2009 3:32 AM
|
|
|
|
|
[edit]Looks like that Format call is your problem - once I realised I'd not converted one of your strings to Unicode, I was able to run your code all the way through with no exceptions (I commented out the FillData call, as that's not available)[/edit]
One issue you might have - this line:
strConfig.Format("CREATE_DB=\"%s\"\0SystemDB=my workgroup.mdw"
"\0UID=Pani\0\0",m_fileName);
Won't produce what you expect - CString::Format won't look beyond your first NULL character, so the string will end up as
CREATE_DB="whatever m_fileName is"
If you use some code like this:
std::basic_string<TCHAR> s;
s = _T("CREATE_DB=\""); s+= m_fileName ; s += _T("\"");
s += TCHAR(0);
s += _T("SystemDB=my workgroup.mdw");
s += TCHAR(0);
s += _T("UID=Pani");
s += TCHAR(0);
s += TCHAR(0);
s += TCHAR(0);
then the string will be created with all the bits in correctly, as std::string doesn't care about nulls as much as CString . You can pass s.c_str() to your call to SQLConfigDataSource to access the string content.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
modified on Thursday, April 2, 2009 4:51 AM
|
|
|
|
|
Hi Stuart Dootson,
Thanks for providing the hints. I am using VS 2003 (without unicode). Hence, I changed the lines to:
char szConfig[1024];
sprintf(szConfig,"SystemDB=%s%cUID=%s%cCREATE_DB=\"%s\"%c%c",
"my workgroup.mdw",'\0',"Pani",'\0',m_fileName,'\0','\0');
SQLConfigDataSource(NULL, ODBC_ADD_DSN, strAccessDriver,szConfig);
Now it is working fine.
Pani.
|
|
|
|
|
pani68 wrote: Now it is working fine.
Excellent - that's the desired outcome
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I am using unicode in my Program.i have stored a CString value into const void* variable.now i want to convert a const void* into CString where i am unable to convert .
|
|
|
|
|
Assuming the void pointer is called lpvoid, do this -
CString cstring(reinterpret_cast<wchar_t*>(lpvoid));
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Can you show us how you stored the CString into a const void* ?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hello all.
I've a dialog box application and in that i'm taking 2 bitmaps which behaves like buttons.. Initially My OK Bitmap button is disable and CANCEL bitmap button is enabled, I've one field for password, when user gives right password OK bitmap button get enabled and i can click on that....Now my problem is that despite of clicking if user presses ENTER key it should behave like mouse click...
So intot i need to know how to capture Enter Key.. Small search gave me that i need to handle WM_KEYDOWN and VK_RETURN...
Thanks all
|
|
|
|
|
Assuming you are using MFC, simply override the OnOK() and OnCancel() in you dialog class.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Damn.. I always forgot to tell you guys it's NON-MFC..
Sorry ..
|
|
|
|
|
Hey!
On a side note: having a button that gets enabled when a correct password is entered makes it a bit easier to guess the password by bruteforce (or/and maybe other methods) because one only has to write a program that enters a password and then checks the state of the button, if it is disabled, it tries the next possible password and checks the button again until the button becomes enabled... althorough you can add a -let's say- 3 seconds pause if a wrong password is entered before the user is allowed to enter the next password, this makes it take much much more time to hack.
Aside of this, did you try handling WM_KEYDOWN? Did it work?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Code-o-mat wrote: Hey!
On a side note: having a button that gets enabled when a correct password is entered makes it a bit easier to guess the password by bruteforce (or/and maybe other methods) because one only has to write a program that enters a password and then checks the state of the button, if it is disabled, it tries the next possible password and checks the button again until the button becomes enabled... althorough you can add a -let's say- 3 seconds pause if a wrong password is entered before the user is allowed to enter the next password, this makes it take much much more time to hack.
That's not the issue
Code-o-mat wrote: Aside of this, did you try handling WM_KEYDOWN? Did it work?
Yes i did.. But it's not working, i tried WM_CHAR also same result
case WM_CHAR :
{
switch(LOWORD(wParam))
{
case VK_RETURN:
MessageBox(hWnd, "Enter Pressed", NULL, NULL);
}
}
case WM_KEYDOWN :
{
switch(LOWORD(wParam))
{
case VK_RETURN:
MessageBox(hWnd, "Enter Pressed", NULL, NULL);
}
}
P.S
BTW the default focus is in password (Edit) box only, Does this create any problem?
|
|
|
|
|
Try catching WM_COMMAND with IDOK as command id.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Code-o-mat wrote: Try catching WM_COMMAND with IDOK as command id.
There's no button in my dialog box, I deleted all, I needed custom buttons so i'm using BITMAP's for that
I also don't want to create button as IDOK and make it invisible.. I hope you're getting my problem..
|
|
|
|
|
You don't need a button for that, if you are using MFC and override OnOK, it will be called when you hit enter EVEN if there is no IDOK or any other button for that matter on your dialog. I am not sure how it works without MFC but it might be worth a try. The keyhits go to the window that owns the input focus so that explains why WM_KEYDOWN in your dialog doesn't work...
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Wow..Your last reply makes it real small problem .. Thanks a lot...
Problem solved
|
|
|
|
|
Great, yourwelcome.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
void CMainWindow::OnPaint ()
{
CPaintDC dc (this);
CBrush brush (RGB (255, 0, 0));
dc.SelectObject (&brush);
dc.Ellipse (0, 0, 200, 100);
}
Here's the problem. A CPaintDC object and a CBrush object are created on the stack. Since the CBrush is created second, its destructor gets called first. Consequently, the associated GDI brush is deleted before dc goes out of scope.
Please can u explain the concept of the above lines in detail....
|
|
|
|
|
You could always create the brush before the DC....
p_1960 wrote: Please can u explain the concept of the above lines in detail....
Which concept? That objects allocated on the stack are destructed strictly in the opposite order to which they were created?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
p_1960 wrote: Please can u explain the concept of the above lines in detail....
Nope, Got better things to do! (Sun is shining...)
But you are right to be slightly concerned.
The brush returned from SelectObject should have been selected back in. You'd almost certainly get away with the code as it is, but "get away with" is hardly good programming.
Better:
void CMainWindow::OnPaint ()
{
CPaintDC dc (this);
CBrush brush (RGB (255, 0, 0));
CBrush *brOld = dc.SelectObject (&brush);
dc.Ellipse (0, 0, 200, 100);
dc.SelectObject (brOld);
}
Iain.
In the process of moving to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), give me a job!
|
|
|
|
|
Hi,
I was wondering if there is a way to retrieve contents of a control(let's take list control) of another application? I think we can reach the control via FindWindowEx. But how we retrieve the contents?
Thanks a bunch!
Neil
|
|
|
|
|
If you have the window handle, you can send it messages. Like, for example, LVM_GETITEM[^], which you use to retrieve item details from a list control.
However, I'm unsure if it'll work cross-process. Try it and see!
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Stealing Program's Memory[^]
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|