|
Hi everybody.
I wanna write an application which has a database created using SQL-Server2000.
In this app I need to have a beautiful graphical user interface and on the other hand have to be able to work with the data tables in an mfc application that is created with vc 2003.(not .net)
what do you suggest?
i think a web service would help if so, can i write it with .net2.0 using c# and asp.net and use the web service with mfc 1.1?
please help me!!!!!!
Sepehr
|
|
|
|
|
How do you convert a array of bitmap bits to a HBITMAP?
I cannot seem to figure it out.
|
|
|
|
|
|
|
Hi,
i am using the function :
FindWindow(LPCTSTR lpszClassName,LPCTSTR lpszWindowName )
and i need to input the lpszClassName of my main frame window created using MFC MDI application.
anyone knows how?
tks.
|
|
|
|
|
From MSDN:
lpClassName
[in] Pointer to a null-terminated string that specifies the class name or a class atom created by a previous call to the RegisterClass or RegisterClassEx function. The atom must be in the low-order word of lpClassName; the high-order word must be zero.
If lpClassName points to a string, it specifies the window class name. The class name can be any name registered with RegisterClass or RegisterClassEx, or any of the predefined control-class names.
If lpClassName is NULL, it finds any window whose title matches the lpWindowName parameter.
You can use that parameter as NULL. and then the program will search for any window with that specific name.
If you want, you can call the functions RegisterClass or RegisterClassEx in order to set the name of that class.
Hope this helps.
|
|
|
|
|
You can use the GetClassName() API on the HWND of your main frame window to get its class name.
You can also set the class name, as Joan Murt suggested.
Mark
|
|
|
|
|
Mark Salsbery wrote: You can use the GetClassName() API on the HWND of your main frame window to get its class name.
Actually, he wanted class name to find window in question. If he had window handle, then there is no question of getting class name.
As somebody already answered, passing NULL for classname he can find window.
|
|
|
|
|
Gotcha, thanks
I was thinking if he needed the classname that MFC uses when it registers the class. Just
do it once so he'd know whe string to use in the other app. It made sense to me when I typed
the vague reply Using the title is much easier.
Thanks for the correction!
Mark
|
|
|
|
|
I have gone through the directX SDK. I am a bit confused with the routines given in the MS Visual C++ documentation of using DirectX API's. I would need a small help in getting the sequence of calling the API's to show an image(just pixel values) stored in memory.I can do it only in a plain Win32 project or MFC based project.
|
|
|
|
|
I have a CListBox that get some text. I want to go to the last input so I can see what text its comming. How can I do that?
|
|
|
|
|
Hello Larsson,
You should get the number of items using GetCount();
and then use GetText(int A, CString &CS);
Where A must be the index of the last item.
Where CS must be a receiver CString.
Hope this helps.
|
|
|
|
|
I cant get this to work, can you please typ a exemple here so I can see.
I hace try to use this,
iGo = m_AddLogg.GetCount();
m_AddLogg.GetText(iGo, sText);
But this dont make me go down in the list. Note that sText in this case is emty.
|
|
|
|
|
Larsson wrote: iGo = m_AddLogg.GetCount();
m_AddLogg.GetText(iGo, sText);
Index is zero based, so you need to use following code,
iGo = m_AddLogg.GetCount();
m_AddLogg.GetText((iGo-1), sText);
|
|
|
|
|
Weekend, sorry, I hope that the answer from prasad_som has been useful.
Good luck...
|
|
|
|
|
Please help me,
When does user insert CD into driver CD.I want my program will automatically detect and show all of them(file and folder) are showed in a listbox.
My program is written y MFC
Thank you very much.
|
|
|
|
|
You need to create an AutoRun.Inf file that will inform Windows which program to run when the CD is inserted into the drive.
You can have it run your special program with the list in it you want.
|
|
|
|
|
Forgive me is this is a stupid question, but I'm kinda new to DirectX. I'm drawing 2D images using textured quads. Is it possible to draw two textures at the same time onto a single quad? I could do this by swapping the texture and drawing the sprite twice, but surely there is a way to do this in one blow.
|
|
|
|
|
Hi
I have an SDI application. The CMainframe currently has a CSplitterWnd embedded in it. In order to prevent over-crowding, I would like to add a CTabCtrl to intervene in between the CMainframe and the CSplitterWnd, such that the first tab shows the CSplitterWnd, and the other tabs show different views, and the user can move between the views without the views re-initialisaing. (Much like the "Contents / Index / Search / Favourites" tabs in the help system of VC++.)
What's the simplest way to achieve this please?
cheers,
Neil
|
|
|
|
|
I created a edit box just fine, but when i trying to select the text in it, the application for some reason does not do it, Im not sure what's missing. Here is the part of the code that Im talking about:
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
#define IDC_MAIN_EDIT 1
#define IDC_SEDIT 2
#define IDC_BUTTON 3
HWND iEdit, rEdit, button;
switch(msg)
{
case WM_COMMAND:
if( wParam == IDC_BUTTON )
{
MessageBox( hwnd, "Button was clicked.", "Notification", MB_OK );
SetDlgItemText(iEdit, IDC_MAIN_EDIT, "testing");
}
break;
case WM_CREATE:
{
iEdit = CreateWindowEx(WS_EX_CLIENTEDGE, "EDIT", NULL,
WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_HSCROLL |
}
...
}
when the WndProc receives the button message, a message box will appear saying i pressed the button, and the text in the iEdit control is suppose to be set to "testing" right? I really don't know what Im missing.
|
|
|
|
|
actually i just solved it myself. I didnt realize that when calling the SetDlgItemText(iEdit, IDC_MAIN_EDIT, "testing"); command, the first parameter corresponds to the parent window that the target edit box belongs to, no wonder we need to specify the edit box control id in the second parameter.
|
|
|
|
|
Can anyone provide a pointer to a class or library that supports adding extra buttons to a window's caption bar? Support for XP themes is required.
|
|
|
|
|
|
Hi all, I have a program that needs to pick up the contents of a
SysListView in another process. As you are all aware this requires me
allocating memory for my strings and the LVITEM structure in the other
process, then writing to them and sending the message and then reading
from them.
My code works, this might seem like a strange post but wait the plot
thickens.I tested this program on the task manager, It has four of
these SysListViews hanging around so It seemed as good a candidate as
any for my experiment. I watch the process locate the window (the title
changes so I had to do an enumwindows to find it) then I did an
enumchildwindows in order to find all the SyslistViews. Now I getting
somewhere I think to my self. I call my home-grown C dll with my window
handles and I get the thread and process responsible for these
critters.
I set my debug priveleges and and ask for my window handle "all
access". I allocate my memory watch my lil pointers come back and send
my message and readprocessmemory back into my address space, and
gleefully see the pointers filled with strings from the task manager.
This is where it gets interesting. I change my window title to the name
of the the title to the part of the name of the MDI window that I am
interested in. I get my handles, my process handle, and allocate my
memory, The first call works great, then the problems start ;( The
second call to virtualallocex succeeds but the pointes now have the
"bad ptr" following the address that was allocated, "that wasn't there
on the other window" I think to myself, and sure enough the strings
come back empty.
So I decide to google this one. Two days of googling and no cigar.
While googling I also decided that virtualallocex wasn't to be trusted
to find the base address in the other process, so I decided to walk the
vad and find my own address, this worked as well, and I locate memory
locations large enough to hold my memory , but still no cigar. It works
for the task manager but not the target program ;(
By this time I have almost read anything I could find on virtualallocex
and by passing most of the other virtual memory functions, I fiddled
with virtualqueryex and virtualprotectex, trying to find the problem.
FormatMessage came to mind pretty quickly but "The operation completed
successfully" isn't much help when trying to debug code that is
anything but successful.
At this point let me try to give you a description of my environment:
Window XP PRO SP2 latest updates.
VS.NET 2003, latest updates Enterprise Architect.
An old, P III 500 that if I could get the project to work would provide
me with some cash to buy one of the latest beasts available.
256 Mb of ram (always a drag that swapping ;()
The program I am trying to infiltrate is
EFX Navigator on www.efxgroup.com
For my info tell me what you need, I can get back to you.
Here is my soucre code, The first part is a VB.net module the second
part is as VC++ Win32 dll (hence why I posted here)
This code is anything but tidy but with all the debuging I'm doing
cleaning up old code (that works on the taskmanager and other programs)
doesn't seem like a good approach
Any way here it is:
VB.net Code First
-----------------------------------------------------------------------------------------------------------------------------------------------------
Imports System
Imports System.Runtime.InteropServices
Imports System.Text
Module MainModule
'FormatMessage
<dllimport("kernel32.dll", entrypoint:="FormatMessageA" ,="" _
="" charset:="CharSet.Ansi," exactspelling:="True," callingconvention:="CallingConvention.StdCall)"> _
Private Function FormatMessage( _
ByVal dwFlags As Int32, ByVal lpSource As Int32, _
ByVal dwMessageId As Int32, ByVal dwLanguageId As Int32, _
ByVal lpBuffer As StringBuilder, _
ByVal nSize As Int32, ByVal Arguments As Int32) As Int32
End Function
Private Const FORMAT_MESSAGE_ALLOCATE_BUFFER As Long = &H100
Private Const FORMAT_MESSAGE_FROM_SYSTEM As Long = &H1000
Private Const FORMAT_MESSAGE_IGNORE_INSERTS As Long = &H200
Private Declare Function GetLastError Lib "kernel32.dll" () As
Integer
'declare API functions
Private Delegate Function EnumChildProcDelegate _
(ByVal hWnd As IntPtr, _
ByVal lParam As Integer) As Boolean
Private Declare Function EnumChildWindows Lib "user32" _
(ByVal hWndParent As IntPtr, _
ByVal lpEnumFunc As EnumChildProcDelegate, _
ByVal lParam As Integer) As Boolean
Declare Function GetClassName Lib "user32.dll" Alias
"GetClassNameA" _
(ByVal hwnd As IntPtr, _
ByVal lpClassName As StringBuilder, _
ByVal nMaxCount As Long) As Long
Private Declare Ansi Function FindWindow Lib "user32" Alias
"FindWindowA" _
(ByVal lpClassName As StringBuilder, ByVal lpWindowName As
StringBuilder) As IntPtr
Public Declare Sub GetWindowText Lib "user32.dll" _
Alias "GetWindowTextA" (ByVal hWnd As IntPtr, _
ByVal lpString As StringBuilder, _
ByVal nMaxCount As Integer)
Private Declare Function SendMessage Lib "user32" Alias
"SendMessageA" _
(ByVal hwnd As IntPtr, ByVal wMsg As Integer, _
ByVal wParam As Integer, _
ByVal lParam As String) As Integer
Public Declare Function GetWindow Lib "user32.dll" _
Alias "GetWindow" (ByVal hwnd As Integer, _
ByVal wCmd As Integer) As Integer
'Top Level enumeration
Public Delegate Function EnumWindowsCallback(ByVal hWnd As IntPtr,
_
ByVal lParam As
Integer) As Boolean
Public Declare Function EnumWindows Lib "user32.dll" _
Alias "EnumWindows" (ByVal callback As EnumWindowsCallback, _
ByVal lParam As Integer) As Integer
<dllimport("user32.dll", entrypoint:="EnumWindows" ,
setlasterror:="True," _
="" charset:="CharSet.Ansi," exactspelling:="True," callingconvention:="CallingConvention.StdCall)"> _
Public Function EnumWindowsDllImport(ByVal callback As
EnumWindowsCallback, _
ByVal lParam As
Integer) As Integer
End Function
'My DLL Declares
Private Declare Function CopyListViewToListBox Lib "Extract Data
Library.dll" _
Alias "CopyListViewToListBox" (ByVal SourceHwnd As IntPtr, ByVal
TargetHwnd As IntPtr, _
ByVal Append As Boolean) As Integer
Private Declare Function FillListBox Lib "Extract Data Library.dll"
_
Alias "FillListBox" (ByVal targetHwnd As IntPtr, ByVal item As
String, _
ByVal subitem As String, ByVal Append As
String) As Integer
'Variables
Dim iFound As Int32
Dim aihWnds As ArrayList
Private Const WM_GETTEXT = &HD
'Listbox Functions
Private Declare Function LockWindowUpdate Lib "user32" (ByVal
hwndLock As IntPtr) _
As Long
'Listbox Constants
Const LB_RESETCONTENT = &H184
Const LB_GETCOUNT = &H18B
Const LB_GETTEXT = &H189
Const LB_ADDSTRING = &H180
Const LB_GETITEMDATA = &H199
Const LB_SETITEMDATA = &H19A
Function GetGlass(ByVal hwnd) As String 'classe de la fenetre
Dim sClassName = New StringBuilder(256)
GetClassName(hwnd, sClassName, 256)
sClassName = Left$(sClassName, InStr(sClassName, Chr(0)) - 1)
Return sClassName
End Function
Function GetCaption(ByVal hwnd As IntPtr) As String 'titre du
document
Dim sCaption = New StringBuilder(256)
GetWindowText(hwnd, sCaption, 256)
sCaption = sCaption.ToString
If Len(sCaption) > 1 Then
Debug.WriteLine(sCaption)
If (InStr(sCaption, Chr(0)) - 1) > 0 Then 'trim null
sCaption = Left$(sCaption, InStr(sCaption, Chr(0)) - 1)
End If
End If
Return sCaption
End Function
Function GetCaptionFromMessage(ByVal hwnd) As String 'texte titre
fenetre
Dim sCaption = New String(Chr(0), 100)
Dim retval = SendMessage(hwnd, WM_GETTEXT, 100, sCaption)
sCaption = Left$(sCaption, InStr(sCaption, Chr(0)) - 1)
Return sCaption
End Function
Function EnumChildrenProc(ByVal hwnd As IntPtr, ByVal lParam As
Integer) As Boolean
Dim retval As Long
'error handling goes here good old formatmessage from system
Dim ClassName As New StringBuilder(256)
retval = GetClassName(hwnd, ClassName, 256)
If ClassName.ToString = "SysListView32" Then
'found listbox
Debug.WriteLine(hwnd)
'FillListbox(hwnd)
MainModule.aihWnds.Insert(iFound, hwnd)
iFound = iFound + 1
End If
'If iFound = 1 Then
'Return False 'Found Both of the Listbox Stop enumeration
'Else
Return True 'Still haven't got them both
'End If
End Function
Sub GetListBoxes()
'need to loop through all windows to get the first characters
and compare to level II ...
'Dim sWindowCaption = "Windows Task Manager"
'Dim hwnd = FindWindow(vbNullString, sWindowCaption)
Dim proc As New EnumWindowsCallback(AddressOf
MainModule.EnumWindowProc)
EnumWindows(proc, 0)
'DuplicateListBox(MainForm.Listboxes(0).Handle,
MainForm.Listboxes(1))
End Sub
Private Function EnumWindowProc(ByVal hwnd As IntPtr, ByVal lParam
As Integer) As Boolean
If InStr(GetCaption(hwnd).ToString, "Level II") Then
ProcessEFXChildren(hwnd)
Return False
End If
Return True
End Function
Private Function ProcessEFXChildren(ByVal hwnd As IntPtr)
iFound = 0
aihWnds = New ArrayList
Dim i As Integer
Dim proc As New EnumChildProcDelegate(AddressOf
MainModule.EnumChildrenProc)
Dim retval = EnumChildWindows(hwnd, proc, 0&)
For i = 0 To iFound - 1
CopyListViewToListBox(aihWnds(i),
MainForm.Listboxes(0).Handle, False)
Next
End Function
End Module
---------------------------------------------------------------------------------------------------------------------------------------------
VC++.NET DLL CODE
// Extract Data Library.cpp : Defines the entry point for the DLL
application.
//
//Defines
#define WIN32_LEAN_AND_MEAN
//Includes
#include "stdafx.h"
#include <stdio.h>
#include <windows.h>
#include <commctrl.h>
#define My_EXPORTS //Define in order to
export functions
#include "Extract Data Library.h"
#include <string>
#include <cstdlib>
#include "stdlib.h"
//Declares Exported Functions
//Delcares Internal Functions
DWORD DoFormatMessage();
DWORD DoDebugFormatMessage();
int SetDebugPrivileges(void);
MEMORY_BASIC_INFORMATION WalKingTheVAD(HANDLE hProcess, DWORD
RequiredSpace);
//Exported Variables
//Global Variables
//DLL ENTRRY POINT
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
//Code Starts here
My_API_Export int __stdcall CopyListViewToListBox(HWND SourceHwnd, HWND
TargetHwnd, BOOL Append)
{
SetDebugPrivileges();
HWND listview= SourceHwnd;
int count=(int)SendMessage(listview, LVM_GETITEMCOUNT, 0, 0);
int i;
LVITEM lvi, *_lvi;
char item[512], subitem[512];
char *_item, *_subitem;
unsigned long pid;
HANDLE process;
MEMORY_BASIC_INFORMATION mbi;
LPVOID BaseAddress = 0;
GetWindowThreadProcessId(listview, &pid);
//process=OpenProcess(PROCESS_VM_OPERATION|PROCESS_VM_READ|
//
PROCESS_VM_WRITE|PROCESS_QUERY_INFORMATION, FALSE, pid);
process=OpenProcess(PROCESS_ALL_ACCESS,false, pid);
//DoFormatMessage();
mbi = WalKingTheVAD(process, (DWORD)(sizeof(LVITEM)) );
if (mbi.BaseAddress ==NULL)
{
MessageBox(NULL, "Insufficient Memory in Target Process
to Extract
Data","Fatal Error", MB_ICONERROR);
return -1;
}
BaseAddress = mbi.AllocationBase;
_lvi=(LVITEM*)VirtualAllocEx(process, BaseAddress,
sizeof(LVITEM),
MEM_COMMIT, PAGE_READWRITE);
if (_lvi == NULL) DoFormatMessage();
mbi = WalKingTheVAD(process, (DWORD)(100) );
if (mbi.BaseAddress ==NULL)
{
MessageBox(NULL, "Insufficient Memory in Target Process
to Extract
Data","Fatal Error", MB_ICONERROR);
return -1;
}
BaseAddress = mbi.AllocationBase;
_item=(char*)VirtualAllocEx(process, BaseAddress, 100,
MEM_COMMIT,
PAGE_READWRITE);
DoFormatMessage();
_subitem=(char*)VirtualAllocEx(process,NULL, 100, MEM_COMMIT,
PAGE_READWRITE);
DoFormatMessage();
/*
_lvi=(LVITEM*)VirtualAllocEx(process, NULL, sizeof(LVITEM),
MEM_COMMIT, PAGE_READWRITE);
_item=(char*)VirtualAllocEx(process, NULL, 512, MEM_COMMIT,
PAGE_READWRITE);
_subitem=(char*)VirtualAllocEx(process, NULL, 512, MEM_COMMIT,
PAGE_READWRITE);
*/
lvi.cchTextMax=512;
for(i=0; i
|
|
|
|
|
Is the following utility successful in getting the contents of the list view?
FWIW, here is a clever utility that copies the text of another process's controls to the clipboard. The controls that are supported are Edit (including obscured password edits), Static, Headers, Listview, ComboBox and ListBox. Source code (GPL'd) is included: "Control Content Saver" by Jacquelin Potier at http://jacquelin.potier.free.fr/controlcontentsaver/[^]
If the code at the above site works, whereas yours doesn't, then compare code.
If the code at the site doesn't work either, then you might not be looking at an ordinary list view control. Are you 100% certain that the windows class is SysListView(32)? Double-check with Spy++. If it's definitely a SysListView, then also check the style flags. Maybe it's an owner-data (i.e., a virtual list view) or owner-drawn, or both.
Mike
|
|
|
|
|