Integration of individual two-dimensional materials into heterostructures is a crucial step which enables development of new and technologically interesting functional systems of reduced dimensionality. Here, well-defined lateral heterostructures of hexagonal boron nitride and graphene are synthesized on Ir(111) by performing sequential chemical vapor deposition from borazine and ethylene in ultra-high vacuum. Low-energy electron microscopy (LEEM) and selected-area electron diffraction (µ-LEED) show that the heterostructures do not consist only of hexagonal boron nitride (an insulator) and graphene (a conductor), but that also a 2D alloy made up of B, C, and N atoms (a semiconductor) is formed. Composition and spatial extension of the alloy can be tuned by controlling the parameters of the synthesis. A new method for in situ fabrication of micro and nanostructures based on decomposition of hexagonal boron nitride is experimentally demonstrated and modeled analytically, which establishes a new route for production of BCN and graphene elements of various shapes. In this way, atomically-thin conducting and semiconducting components can be fabricated, serving as a basis for manufacturing more complex devices. arXiv:1806.03892v1 [cond-mat.mes-hall]