Click here to Skip to main content
15,891,976 members
Articles / Desktop Programming / MFC

How to use Dynamic External MFC CView Class Objects (which exists in a DLL library) in a VBA Host MFC Application

Rate me:
Please Sign up or sign in to vote.
1.00/5 (10 votes)
8 Dec 20023 min read 57.3K   389   11  
Implement interface between two existing DLL Library in a VBA Host MFC application.
<HTML>
<HEAD>
<META name=VI60_defaultClientScript content=VBScript>
<TITLE></TITLE>
<SCRIPT ID=clientEventHandlersVBS LANGUAGE=vbscript>
<!--
dim curlab,wndidtp

wndidtp=" "

set curlab = nothing

sub showpage(this,pag)
	dim a ,b
	set a = d1.all.tags("table")

	if not curlab is nothing then
	  if curlab is this then
		exit sub
	  end if
	  curlab.className = "tabnosel"
	end if

	this.className = "tabsel"
	set curlab = this
	for each b in a
		if b.classname="tabpage" then
			if b is pag then
				'b.style.zIndex = 1
				b.style.display=""
			else
				'b.style.zIndex=-1
				b.style.display="none"
			end if
		end if
	next
end sub

Sub init
	dim a ,b
	set a = d1.all.tags("table")
	'msgbox a.length
	pp.style.display = ""

	for each b in a 
		if b.classname="tabpage" then
			b.style.position="absolute"
			b.style.top =pp.offsetTop 
			b.style.left =pp.offsetleft
			b.style.width =pp.style.width 
			b.style.height =pp.style.height 
		end if
	next
	pl0.style.position="absolute"
	pl1.style.position="absolute"
	pl2.style.position="absolute"
	showpage tdw,tbw
End Sub

sub showtext(pl)
	strabout = "about:" & Space(50) &  "<html><head><title></title></head><body><table id="&pl.id&">" & pl.innerhtml & "</table></body></html>" & _
		"<script language=jscript>function wnd_onmousedown(o){}function wnd_onmouseup(o){} function showtext(o){window.close();}</" & "script>"
	showModalDialog  strabout ,,"dialogheight:" & pl.h & "px;dialogwidth:" & pl.w & "px;status:no;help:no"
	exit sub
	if pl.style.display="none" then
		pl.style.display=""
	else
		pl.style.display="none"
	end if
end sub

sub displayboard
	dd0.style.display="none"
	dd1.style.display=""
	init
end sub
sub SetDocTitle(strTitle)
	window.external.DocTitle = strTitle
end sub
sub SetDocCls(strComClsID)
	window.external.DocComClsID=strComClsID
end sub

Sub ttpl0_onmousemove
	'ttpl0.innerText = window.event.x & "," & window.event.y 
End Sub

dim dx,dy,ox,oy,md,plx
set plx = nothing
Sub wnd_onmousedown(pl)
	'pl0.style.position="absolute"
	'msgbox pl0.style.left
	if not plx is nothing then
		plx.style.zindex = 1
		pl.style.zindex = 2
	end if
	set plx=pl
	dx = window.event.x + document.body.scrollleft
	dy = window.event.y + document.body.scrolltop
	ox = plx.offsetLeft 
	oy = plx.offsetTop
	md = 1 
End Sub

Sub wnd_onmouseup
	md = 0 
	'set plx = nothing
End Sub

Sub document_onmousemove
	if window.event.button = 1 and md = 1 and not plx is nothing then
		plx.style.left = ox - dx + window.event.x + document.body.scrollleft
		plx.style.top = oy - dy + window.event.y + document.body.scrolltop
	end if
	'	ttpl0.innerText ="dsfdsgfdg"
End Sub

dim cnt
sub showtooltip(obj)
	if obj.showtip=0 then
		obj.showtip=1
		obj.timerid= setInterval( "opentooltip " & obj.id & "," & window.event.x & "," & window.event.y,500)
	elseif obj.showtip=1 then
		clearInterval obj.timerid
		obj.timerid= setInterval( "opentooltip " & obj.id & "," & window.event.x & "," & window.event.y,500)
	end if
end sub

'dim ttip,tid
sub opentooltip(obj,x,y)
	
	obj.showtip=2
	tipwnd.style.left = x + 8 + document.body.scrollleft
	
	tipwnd.style.top  = y + 8 + document.body.scrolltop
	tipwndtext.innerText = obj.tooltip
	tipwnd.style.display=""
	clearInterval obj.timerid
end sub

sub canceltooltip(obj)
	tipwnd.style.display="none"
	obj.showtip=0
	clearInterval obj.timerid
end sub
Sub window_onload
	tipwnd.style.display="none"
	tipwnd.style.position="absolute"

End Sub

-->
</SCRIPT>
<style>
INPUT
{
    BORDER-RIGHT: #08246b 1px solid;
    BORDER-TOP: #08246b 1px solid;
    FONT-SIZE: 12px;
    BORDER-LEFT: #08246b 1px solid;
    BORDER-BOTTOM: #08246b 1px solid;
    HEIGHT: 18px
}
.none{
}
.tabsel{
		BORDER-LEFT: silver 1px solid; 
		BORDER-RIGHT: black 1px solid; 
		BORDER-TOP: silver 1px solid;
		CURSOR: default;
		TEXT-ALIGN: center;
		BACKGROUND-COLOR: lightcyan;
		FONT-SIZE: 12px;
		height:22px
		}
.tabnosel{
		BORDER-BOTTOM: silver 1px solid; 
		BORDER-LEFT: silver 1px solid; 
		BORDER-RIGHT: black 1px solid; 
		BORDER-TOP: silver 1px solid;
		CURSOR: default;
		TEXT-ALIGN: center;
		BACKGROUND-COLOR: lightsteelblue;
		FONT-SIZE: 12px;
		height:22px
		}
.ttcap{
		BORDER-BOTTOM: silver 1px solid; 
		BORDER-LEFT: silver 1px solid; 
		BORDER-RIGHT: black 1px solid; 
		BORDER-TOP: silver 1px solid;
		CURSOR: default;
		TEXT-ALIGN: left;
		BACKGROUND-COLOR: lightsteelblue;
		FONT-SIZE: 12px;
		height:20px
		}
.tooltip{
		BORDER-BOTTOM: 1px solid; 
		BORDER-LEFT: 1px solid; 
		BORDER-RIGHT: 1px solid; 
		BORDER-TOP: 1px solid;
		padding-left:2px;
		padding-right:2px;
		CURSOR: default;
		TEXT-ALIGN: left;
		BACKGROUND-COLOR: #ffffe1;
		FONT-SIZE: 12px;
		height:1;
		LINE-HEIGHT: 1.4;
		}
.tabpage{
		BORDER-LEFT: silver 1px solid; 
		BORDER-RIGHT: black 1px solid; 
		BORDER-BOTTOM: black 1px solid;
		BACKGROUND-COLOR: lightcyan;
		FONT-SIZE: 12px;
		width:400
		}
.intabpage{
		FONT-SIZE: 12px;
		width:100%
		}
.txtdlg{
		BORDER-LEFT: silver 1px solid; 
		BORDER-RIGHT: black 1px solid; 
		BORDER-BOTTOM: black 1px solid;
		BORDER-TOP: silver 1px solid;
		BACKGROUND-COLOR: lightcyan;
		FONT-SIZE: 12px;
		width:600
		}

</style>
</HEAD>
<BODY background="CIRCUIT.JPG">
<div id   ="dd0" align ="center" title="Welcome to the world of the Tangram"><font onclick="displayboard" color=blue style="CURSOR: hand"><u>DESIGN</u></font></div>
<div id=dd1 style="DISPLAY: none">
<table border=0 cellPadding=0 cellSpacing=0 width=400><tr>
<td id=tdw onclick="javascript:showpage(this,tbw);" class=tabsel width="20%">Welcome
<!--td id=td0 onclick="javascript:showpage(this,tb0);" class=tabnosel>ControlBar-->
<td id=td1 onclick="javascript:showpage(this,tb1);" class=tabnosel width="20%"
	title="Create Splitter Window">Splitter
<td id=td2 onclick="javascript:showpage(this,tb2);" class=tabnosel width="20%"
	title="Create Tab Window">TABWnd
<td id=td3 onclick="javascript:showpage(this,tb3);" class="tabnosel" 
    title="Create COM Window" width="20%">COM Wnd
<!--td id=td4 onclick="javascript:showpage(this,tb4);" class=tabnosel>Document&nbsp;-->
<td id=td5 onclick="javascript:showpage(this,tb5);" class=tabnosel width="20%">About
<!--td bgcolor=red><A href="javascript:showpage(tbr);">��Ʒָ��</A>
<td bgcolor=orange><A href="javascript:showpage(tbo);">Create TAB Window</A>
<td bgcolor=yellow><A href="javascript:showpage(tby);">���COM����</A>
<td bgcolor=green><A href="javascript:showpage(tbg);">����ĵ�����</A-->
</td></tr>
</table>
<table id=pp width=400 height=100 style="DISPLAY: none; HEIGHT: 100px">
<tr><td></td></tr></table>
<div id=d1>
<table id=tbw width=500 class=tabpage>
  <TR>
    <TD>
      <P id=First align=center ><FONT 
      color=blue>Welcome To<FONT 
      size=5><STRONG><EM>TangramAppServer</EM></STRONG></FONT></FONT><br>&nbsp;       
      <U onclick="showtext(pl0)" style="CURSOR: hand; COLOR: blue"   
      color="blue">About...</U></P></TD></TR>  

</table>
<!--table id=tb0 width=500 class=tabpage>
  <TR>
    <TD>
      <P>ControlBarTitle:<INPUT name=strDockBarCaption size="17">&nbsp;</P>
      <P><INPUT name=CreateDockingBar onclick=javascript:window.external.CreateDockBar(strDockBarCaption.value) type=button value=CreateDockingControlBar></P></TD></TR>
</table-->
<TABLE id=tb1 width=500 class=tabpage>
	<TR><TD><Table border=0 cellpadding=0 cellspacing=0 class=intabpage><TR>
	  <TD>Rows:</TD>
	  <TD><INPUT id=RowCount size=1 title='Spliter window rows count'
	    style="WIDTH: 18px" height ="0"></TD>
	  <TD>Columns:</TD>
	  <TD width=70%><INPUT id=ColCount size=1 title='Spliter window columns count'
	    style="WIDTH: 18px" height ="0"></TD>
	  <TR>
	    <TD><!--Title:--></TD>
	    <TD colspan=3><!--INPUT name=SplitterTitle 
	    size=18--></TD>
	  <TR>
	    <TD colspan=4><INPUT name=buttonSplitter onclick='javascript:window.external.CreateSplitter(RowCount.value, ColCount.value, "", 0)' type=button value=CreateSplitter
	    > <INPUT id=DeleteSplitter name=DeleteSplitter  onclick="javascript:window.external.DeleteSplitter()" type=button value="delete splitter"></TD>
	</TR></table>
</TABLE>
<TABLE id=tb2 class=tabpage width=500>
  <TR><TD><Table border=0 cellpadding=0 cellspacing=0 class=intabpage><TR>
    <TD>TabClsID:</TD>
    <TD><INPUT id=Text6 name=txtTabWndClsID size="13" style="WIDTH: 140px" height ="0" width="140"></TD>
    <TD><!--object name:--></TD>
    <TD><!--INPUT name=txtTabWndObjName size="14"--></TD>
  <TR>
    <TD>TabTitle:</TD>
    <TD><INPUT id=Text8 name=txtTabWndCaption style="WIDTH: 140px" width="140"
    title='Fill caption of tabpage'></TD>
    <TD>TabIconIndex:</TD>
    <TD width=15%><INPUT title='Index of added tabpage' value=0
    id=TabImageIndex size=3 style="LEFT: 286px; WIDTH: 22px; TOP: 21px" name=TabImageIndex height="0"></TD>
  <TR>
    <TD colspan=4><INPUT name=CreateTabWnd onclick='javascript:window.external.CreateTabWnd(txtTabWndClsID.value, txtTabWndCaption.value, "")' type=button value=CreateTabWnd style="WIDTH: 96px" height ="0">
	<INPUT id=AddPage name=AddPage onclick="javascript:window.external.AddPage(0, txtTabWndCaption.value, TabImageIndex.value)" type=button value="add page" style  ="WIDTH: 74px" height="0">
	<INPUT id=DeletePage name=DeletePage onclick="javascript:window.external.DeleteTabPage(TabImageIndex.value)" type=button value="delete page" style  ="WIDTH: 85px" height="0"> 
	<INPUT id=DeleteTabWnd name=DeleteTabWnd onclick="javascript:window.external.DeleteTabWnd()" type=button value="delete tabwnd"></TD>
  </TR>
</TABLE></TABLE>
<TABLE id=tb3 class=tabpage width=500>
  <TR><TD><Table border=0 cellpadding=0 cellspacing=0 class=intabpage><TR>
    <TD>COMWndID:</TD>
    <TD><INPUT id=txtWndClsID name ="txtWndClsID"  
title='COM Window ClSID,
include ActiveX Object ProgID and Tangram Component ID,
for example ListView Control ProgID is "mscomctllib.listviewctrl",
Tangram Component ID is Component Library name and MFC Component Class Name,
for example "TangramDlllib1.CYourView", 
if the MFC Component Class builed in Application Framework,the Component ID is MFC Component Class Name only .
'></TD>
    <TD><INPUT onclick='javascript:window.external.CreateActiveItem(txtWndClsID.value, "")' type=button value="Create COM Window" name=CreateCOMWnd style="WIDTH: 150px; HEIGHT: 18px" size=15></TD>
  </TR>
  <!--TR>
    <TD>Object Name:</TD>
    <TD><INPUT id=txtWndObjName name  ="txtWndObjName" style="WIDTH: 47px;    
      HEIGHT: 18px" size  =7 
      title="Click here goto Designer"></TD-->
</TABLE></TABLE>
<!--TABLE id=tb4 class=tabpage width=500>
  
  <TR>
    <TD>
DocTitle:&nbsp;&nbsp;&nbsp;<INPUT id=txtDocTitle name=txtDocTitle size=18 style="WIDTH: 230px" height="0"><BR>
DocobjID:<INPUT id=txtDocCtrlCls name=txtDocCtrlCls size="14" style="WIDTH: 183px" height ="0"><BR>
<INPUT id=DocTitle name=DocTitle onclick="vbscript:setdoctitle(txtDocTitle.value)" type=button value=doctitle>&nbsp;<INPUT id=Comcls name=DocCtrlCls onclick="vbscript:setdoccls(txtDocCtrlCls.value)" type=button value=docctrlcls>&nbsp;<INPUT name=DocProperty onclick=javascript:window.external.DocProperty() type=button value=docproperty id="" style="WIDTH: 66px" height="0">
</TD></TR>
</TABLE-->
<TABLE id=tb5 class=tabpage width=500>
  
  <TR>
    <TD><U onclick="showtext(pl1)" style="CURSOR: hand; COLOR: blue"   
      color="blue"><b 
      >How to create an application with Tangram ?</b></U><br>
<U onclick="showtext(pl2)" style="CURSOR: hand; COLOR: blue"   
      color="blue"><B>How to create a view which can insert into application 
developed by TangramAppServer</B></U> 
    </TD></TR>
</TABLE>
</div>
<table border=1 id=pl0 class=txtdlg style="DISPLAY: none; LEFT: 10px; WIDTH: 431px; TOP: 0px; HEIGHT: 140px" h=250 w=431><tr><td class=ttcap onmousedown=wnd_onmousedown(pl0) id="ttpl0" onmouseup='wnd_onmouseup' dx="0" dy="0" ><b>About 
      Tangram</b><tr><td>
      <FONT>&nbsp;&nbsp;&nbsp; <FONT   
      color=#0000ff>
      <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-ALIGN: center" 
      align=center><SPAN lang=EN-US><FONT face="Times New Roman" color=#000000 
      size=3>Tangram Programming Tool Kit</FONT></SPAN></P>
      <P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><SPAN lang=EN-US><FONT 
      size=3><FONT color=#000000><FONT face="Times New Roman"><SPAN 
      style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
      </SPAN>Tangram is a Programming Tool Kit, you can use it to development 
      Software integrated with Microsoft Visual Basic for Application. If you 
      plan to integrate Microsoft VBA into your software system, or if you wish 
      to design a software system which is a second developing system, Tangram 
      is design for you!</FONT></FONT></FONT></SPAN></P></FONT></FONT>
<BR><center><INPUT  id=button2 name=button2 type=button value=Close onclick="showtext(pl0)"></center>
      </td></tr></table>
<table border=1 id=pl1 class=txtdlg style="DISPLAY: none" h=400 w=610><tr><td class=ttcap onmousedown=wnd_onmousedown(pl1) id="ttpl1" onmouseup='wnd_onmouseup' dx="0" dy="0"><b>How to 
      create an application with Tangram ?</b><tr><td><TEXTAREA class=txtdlg id=textarea1 style="FONT-SIZE: large; WIDTH: 590px; HEIGHT: 318px" name=textarea1 readOnly>If you are a new comer of Tangram:
    Step 1: use Tangram Vba Application wizard to generic an application framework;
    Step 2: use atl object code wizard to insert Tangram Component into your application;
    Step 3: if you want to integrate other component(developed by vb,delphi etc...), please use tangram designer insert them into your document system.
</TEXTAREA><center><INPUT  id=button2 name=button2 type=button value=Close onclick="showtext(pl1)"></center></td></tr>
</table>
<table border=1 id=pl2 class=txtdlg style="DISPLAY: none" h=450 w=610><tr><td class=ttcap onmousedown=wnd_onmousedown(pl2) id="ttpl2" onmouseup='wnd_onmouseup' dx="0" dy="0"><B>How to 
      create a view which can insert into application developed by 
      TangramAppServer</B><tr><td><TEXTAREA class=txtdlg id=TEXTAREA1 style="FONT-SIZE: large; WIDTH: 100%; HEIGHT: 356px" name=TEXTAREA1 rows=1 readOnly>    if you have been created an application, you can create tangram component which can cantain some user view(Mfc CView or Mfc CWnd class object), such component can inside or outside your software, if you plan to create such component inside your software, you can use atl object wizard insert tangram object into your code framework, otherwize, you can create a dll use tangram component wizard, an then, insert tangram component object into this dll......</TEXTAREA>
      <center><INPUT  id=button2 name=button2 type=button value=Close onclick="showtext(pl2)"></center></td></tr>
</table>
</div>
<TABLE id=tipwnd border=0 cellPadding=0 cellSpacing=0 class=tooltip borderColor=black>
  <TR>
    <TD id=tipwndtext></TD></TR></TABLE>
</BODY>
</HTML>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
China China
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions